### Install Digestif Files via Shell Source: https://github.com/astoff/digestif/blob/main/INSTALL.md Uses the install command to copy binaries, Lua modules, and data tags to their respective system directories. ```bash install -Dt $PREFIX/bin bin/digestif install -Dt $PREFIX/share/lua/$LUA_VERSION digestif install -Dt $PREFIX/share/digestif data/*.tags ``` -------------------------------- ### Perform Unbundled Installation Source: https://github.com/astoff/digestif/blob/main/INSTALL.md Installs Digestif into a standalone directory and creates a symbolic link to the executable in the system path. ```bash install -Dt $PREFIX bin data digestif ln -s $PREFIX/bin/digestif /opt/bin/digestif ``` -------------------------------- ### Manage Digestif via Command Line Interface Source: https://context7.com/astoff/digestif/llms.txt Demonstrates common CLI commands for starting the language server, generating documentation tags, and accessing help information. These commands interact with the server via the LSP JSON-RPC protocol over stdio. ```bash digestif digestif --verbose digestif --generate mypackage.sty digestif --version digestif --help ``` -------------------------------- ### Package Tags into Zip Archive Source: https://github.com/astoff/digestif/blob/main/INSTALL.md Creates a zip archive of tag files for optional dependency support and installs the archive to the designated directory. ```bash zip -j data.zip data/*.tags install -Dt $PREFIX/share/digestif data.zip ``` -------------------------------- ### Emacs Lisp Directory Local Variables Setup Source: https://github.com/astoff/digestif/wiki/Editor-configuration Configures Emacs settings for the current directory and its subdirectories. It sets indentation styles, Lua-specific settings like indent level and outline regex, and associates file extensions with lua-mode. This configuration helps maintain consistent coding standards within the project. ```elisp ;;; Directory Local Variables -*- no-byte-compile: t -*- ;;; For more information see (info "(emacs) Directory Variables") ((nil . ((indent-tabs-mode . nil))) (lua-mode . ((lua-indent-level . 2) (outline-regexp . "--\\(\*+\\\\)"))) ("data/" (nil . ((fill-column . 78)))) (auto-mode-alist . (("\\.tags\'" . lua-mode) ("\\.texlua\'" . lua-mode) ("\\.rockspec\'" . lua-mode)))) ``` -------------------------------- ### Configure Data Directories in Digestif Source: https://github.com/astoff/digestif/blob/main/INSTALL.md Configures the data_dirs path within the Digestif script to ensure the application can locate tag files after installation. ```lua require "digestif.config".data_dirs = {"$PREFIX/share/digestif"} ``` ```lua require "digestif.config".data_dirs = {"$PREFIX/share/digestif/data.zip"} ``` -------------------------------- ### Manage Multi-File TeX Projects Source: https://context7.com/astoff/digestif/llms.txt Illustrates how to use TeXShop-style magic comments to define root documents and how to utilize the Digestif Cache module to resolve cross-references across multiple files. ```lua local Cache = require "digestif.Cache" local cache = Cache{ ["main.tex"] = "\\documentclass{book}...", ["chapter1.tex"] = "% !TeX root = main.tex..." } local script = cache:manuscript("chapter2.tex", "latex") local completions = script:complete(#"\\ref{ch:") ``` -------------------------------- ### Fetch Documentation and Signature Help Source: https://context7.com/astoff/digestif/llms.txt Illustrates the use of the describe method to obtain detailed information about a command or item at a specific position. This is primarily used for implementing hover tooltips or signature help in text editors. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["doc.tex"] = [[ \documentclass{article} \begin{document} \cite{knuth84} \end{document} ]] } local script = Manuscript{filename = "doc.tex", format = "latex", files = files} local pos = #[[ \documentclass{article} \begin{document} \ci]] + 1 local help = script:describe(pos) if help then print(help.label) print(help.summary) end ``` -------------------------------- ### Initialize Manuscript and Perform Completions Source: https://github.com/astoff/digestif/wiki/API Demonstrates how to initialize a Manuscript object using a Cache for file management and retrieve completion candidates for a given document position. ```lua Manuscript = require "digestif.Manuscript" Cache = require "digestif.Cache" my_files = Cache {["foo.tex"] = "See \\ci"} my_doc = Manuscript { filename = "foo.tex", format = "latex", files = my_files } items = my_doc:complete(#"See \\ci" + 1) print(#items, items.prefix) for i, item in ipairs(items) do print(i, item.text) end ``` -------------------------------- ### Retrieve Completion Candidates Source: https://context7.com/astoff/digestif/llms.txt Demonstrates how to use the complete method to fetch context-aware suggestions at a specific byte position. It returns metadata including the prefix, candidate kind, and available completion items. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["doc.tex"] = [[ \documentclass{article} \begin{document} \section{First} \label{sec:first} \section{Second} \label{sec:second} See \ref{sec: \end{document} ]] } local script = Manuscript{filename = "doc.tex", format = "latex", files = files} local pos = #[[ \documentclass{article} \begin{document} \section{First} \label{sec:first} \section{Second} \label{sec:second} See \ref{sec:]] + 1 local candidates = script:complete(pos) print(candidates.kind) print(candidates.prefix) ``` -------------------------------- ### Configure Digestif via Environment Variables Source: https://context7.com/astoff/digestif/llms.txt Demonstrates how to set system-level configuration for Digestif using shell environment variables. ```bash export DIGESTIF_DATA="/usr/share/digestif:/opt/digestif/data" ``` -------------------------------- ### Configure Digestif via Lua Module Source: https://context7.com/astoff/digestif/llms.txt Demonstrates how to programmatically configure Digestif settings such as data directories, fuzzy matching, and custom snippets using the digestif.config module. ```lua local config = require "digestif.config" config.data_dirs = {"/usr/share/digestif", "./data"} config.texmf_dirs = {"/usr/share/texmf"} config.fuzzy_cite = true config.fuzzy_ref = true config.extra_snippets = { figure = "figure}\n\\centering\n\\includegraphics{${1:file}}\n\\caption{${2:caption}}\n\\label{fig:${3:label}}\n\\end{figure}$0" } config.load_from_env() config.load_from_table({ fuzzy_cite = false, verbose = true }) ``` -------------------------------- ### URI Schemes for Documentation Source: https://github.com/astoff/digestif/wiki/Tags Illustrates the different URI schemes supported for locating documentation items, including http(s), info, and texmf. ```text info:latex2e#Counters texmf:doc/plain/impatient/book.pdf#page=10 ``` -------------------------------- ### Integrate Digestif with Neovim Source: https://context7.com/astoff/digestif/llms.txt Shows how to configure the Digestif language server in Neovim using the nvim-lspconfig plugin. ```lua local lspconfig = require('lspconfig') lspconfig.digestif.setup{ settings = { digestif = { fuzzy_cite = true, fuzzy_ref = true } } } ``` -------------------------------- ### Initialize Manuscript for Document Analysis Source: https://context7.com/astoff/digestif/llms.txt Shows how to instantiate a Manuscript object using the Digestif Lua API. This requires a Cache object to manage file contents and a specified format to configure the parser. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["main.tex"] = [[ \documentclass{article} \usepackage{tikz} \begin{document} \section{Introduction} \label{sec:intro} See Section~\ref{sec: \end{document} ]] } local script = Manuscript{ filename = "main.tex", format = "latex", files = files } print(script.filename) print(script.format) ``` -------------------------------- ### Define Custom Tags File Source: https://context7.com/astoff/digestif/llms.txt Shows the structure of a .tags file for defining package-specific commands and environments, including metadata for documentation and argument completion. ```lua ctan_package = "mypackage" dependencies = {"latex"} commands = { mycmd = { summary = "A custom command.", arguments = {{meta = "text", optional = true}, {meta = "content"}}, documentation = "info:mypackage#mycmd" } } ``` -------------------------------- ### Manage file cache and manuscript creation Source: https://context7.com/astoff/digestif/llms.txt Demonstrates the Cache class for managing file contents, including manual updates, retrieval, and automatic manuscript object creation with root detection. ```lua local Cache = require "digestif.Cache" local cache = Cache{ ["main.tex"] = [[\documentclass{article}\input{chapter1}]], ["chapter1.tex"] = [[\section{First Chapter}]] } cache:put("main.tex", [[\documentclass{book}\input{chapter1}]]) local content = cache("main.tex") cache:forget("chapter1.tex") local script = cache:manuscript("chapter1.tex", "latex") local script2 = cache:manuscript("chapter1.tex", "latex", "main.tex") ``` -------------------------------- ### Cache Constructor and Methods Source: https://context7.com/astoff/digestif/llms.txt Manages file contents and Manuscript object creation with memoization. ```APIDOC ## CLASS Cache ### Description The Cache class manages file contents and Manuscript object creation with memoization. It supports both in-memory content and automatic file reading from disk. ### Methods - **Cache(files)**: Constructor to initialize cache with file contents. - **put(filename, content)**: Updates or adds file content to the cache. - **forget(filename)**: Removes a file from the cache. - **manuscript(filename, format, root)**: Creates a new Manuscript object from the cached file. ``` -------------------------------- ### Integrate Digestif with Emacs Source: https://context7.com/astoff/digestif/llms.txt Provides configuration snippets for setting up Digestif as the language server in Emacs using either Eglot or lsp-mode. ```elisp (add-hook 'LaTeX-mode-hook #'yas-minor-mode) (setq lsp-tex-server 'digestif) (add-hook 'LaTeX-mode-hook #'lsp) ``` -------------------------------- ### Update Cache and Describe Document Content Source: https://github.com/astoff/digestif/wiki/API Shows how to update file content in the cache and use the Manuscript:describe method to retrieve documentation information for a specific position in the document. ```lua my_files:put("foo.tex", "See \\cite") my_doc = my_files:manuscript("foo.tex", "latex") help = my_doc:describe(8) print(help.label, help.summary) ``` -------------------------------- ### Configure Multi-file Root Document Source: https://github.com/astoff/digestif/blob/main/README.md Specifies the root file for a multi-file TeX project using a magic comment. This allows the language server to correctly resolve cross-references and citations across different files. ```TeX % !TeX root = somefile.tex ``` -------------------------------- ### Digestif Configuration Options Source: https://github.com/astoff/digestif/wiki/API Details various configuration settings for the digestif library that control data searching, snippet customization, and matching behavior. ```APIDOC ## Digestif Configuration ### Description Configuration options for the digestif library. ### Configuration Settings #### config.data_dirs - **Type**: list of strings - **Description**: A list of directories where data files are searched for. #### config.extra_snippets - **Type**: table (key-value pairs) - **Description**: A table where keys are command names and values are snippet strings. These override the internally computed ones. #### config.fuzzy_cite - **Type**: boolean - **Description**: If true, enable fuzzy matching for citations. Matches are done against the author, year and title. #### config.fuzzy_ref - **Type**: boolean - **Description**: If true, enable fuzzy matching for labels. Matches are done against the text surrounding the label, starting at the command immediately preceding the `\label` command. #### config.info_command - **Type**: string - **Description**: A command used to fetch info pages. This is passed to format with the info node as argument. ``` -------------------------------- ### Digestif Configuration Options (Lua) Source: https://github.com/astoff/digestif/wiki/API Configuration settings for the digestif module. This includes specifying data directories, overriding internal snippets, and enabling/disabling fuzzy matching for citations and references. It also defines the command for fetching info pages. ```lua -- A list of directories where data files are searched for. config.data_dirs = {...} -- A table where keys are command names and values are snippet strings. -- These override the internally computed ones. config.extra_snippets = {...} -- If true, enable fuzzy matching for citations. Matches are done against the author, year and title. config.fuzzy_cite = true -- If true, enable fuzzy matching for labels. Matches are done against the text surrounding the label, starting at the command immediately preceding the `\label` command. config.fuzzy_ref = true -- A command used to fetch info pages. This is passed to format with the info node as argument. config.info_command = "info %q" ``` -------------------------------- ### Configure Emacs Info Directory List (Lisp) Source: https://github.com/astoff/digestif/wiki/Common-installation-issues This Lisp code snippet shows how to customize the Info-directory-list variable in Emacs. It adds a directory containing LaTeX info files to the list, allowing Emacs' info reader to find and display these documentation nodes. ```lisp (add-to-list 'Info-directory-list "/usr/local/texlive/2019/texmf-dist/doc/info") ``` -------------------------------- ### Package Digestif for TeX Distribution Source: https://github.com/astoff/digestif/blob/main/INSTALL.md Creates a zip archive containing Lua files and tags for use with the texlua interpreter. ```bash zip -j digestif.zip digestif/*.lua data/*.tags install -Dt $TEXMF/scripts digestif.zip install bin/digestif.texlua $PREFIX/bin/digestif ``` -------------------------------- ### Generate document outline Source: https://context7.com/astoff/digestif/llms.txt Retrieves a hierarchical table of contents for a manuscript based on sectioning commands. The output is a nested table structure representing the document hierarchy. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["doc.tex"] = [[ \documentclass{article} \begin{document} \chapter{Introduction} \section{Background} \subsection{History} \section{Overview} \chapter{Methods} \section{Setup} \end{document} ]] } local script = Manuscript{filename = "doc.tex", format = "latex", files = files} local outline = script:outline(true) local function print_outline(tbl, indent) indent = indent or 0 for _, item in ipairs(tbl) do print(string.rep(" ", indent) .. item.name) if item[1] then print_outline(item, indent + 1) end end end print_outline(outline) ``` -------------------------------- ### Cache Manuscript Object (Python) Source: https://github.com/astoff/digestif/wiki/API Creates a manuscript object from a given path and TeX format. It supports inferring the root path from magic comments or an explicit root path. This method is memoized for efficiency. ```python def manuscript(path, format, root_path=None): """ Returns a manuscript object with source at `path` and TeX format `format`. The manuscript belongs to a tree of manuscript objects representing the document to which it belongs. The optional `root_path`, if provided, specifies the root of the document. If omitted, the root is inferred from TeXShop-style magic comment at the beginning of the file. This method uses memoization, so that it is efficient to make repeated calls to it. """ pass ``` -------------------------------- ### Documentation Item Descriptor Structure Source: https://github.com/astoff/digestif/wiki/Tags Defines the structure of a documentation item descriptor, which is a dictionary containing a summary and a URI. The URI can point to web resources, info nodes, or TeX related files. ```text { "summary": "a one-line description.", "uri": "the location of the documentation item." } ``` -------------------------------- ### Manuscript:outline(local_only) Source: https://context7.com/astoff/digestif/llms.txt Generates a hierarchical table of contents for the document. ```APIDOC ## METHOD Manuscript:outline(local_only) ### Description Returns a hierarchical table of contents for the document based on sectioning commands. ### Method Lua Method Call ### Parameters #### Path Parameters - **local_only** (boolean) - Optional - If true, only returns the outline for the current manuscript file. ### Response #### Success Response - **outline** (table) - A nested structure representing the document hierarchy, where each item contains a 'name' and 'level'. ``` -------------------------------- ### Manuscript:find_definition(pos) Source: https://context7.com/astoff/digestif/llms.txt Locates the definition of a label, citation, command, or environment at a specific position. ```APIDOC ## METHOD Manuscript:find_definition(pos) ### Description Finds the location where a label, citation, command, or environment is defined. Returns an annotated range with position and manuscript information. ### Method Lua Method Call ### Parameters #### Path Parameters - **pos** (number) - Required - The character position within the manuscript to search from. ### Response #### Success Response - **definition** (table) - An object containing: - **pos** (number): Start position of the definition. - **cont** (number): End position (exclusive). - **manuscript** (table): The manuscript object containing the definition. - **kind** (string): The type of definition (e.g., "label", "cs", "env"). ``` -------------------------------- ### Find all references to a LaTeX element Source: https://context7.com/astoff/digestif/llms.txt Uses the find_references method to retrieve a list of all locations where a specific label, citation, or command is referenced within the document. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["doc.tex"] = [[ \documentclass{article} \begin{document} \label{thm:main} See Theorem~\ref{thm:main}. As shown in \ref{thm:main}, we have... \end{document} ]] } local script = Manuscript{filename = "doc.tex", format = "latex", files = files} local label_pos = #[[ \documentclass{article} \begin{document} \label{thm:ma]] + 1 local refs = script:find_references(label_pos) if refs then for _, ref in ipairs(refs) do print(ref.pos, ref.cont, ref.kind) end end ``` -------------------------------- ### Configure Digestif in Emacs lsp-mode Source: https://github.com/astoff/digestif/blob/main/README.md Sets the default TeX language server to Digestif within the Emacs lsp-mode configuration. This ensures that lsp-mode utilizes the Digestif server for TeX files. ```emacs-lisp (setq lsp-tex-server 'digestif) ``` -------------------------------- ### Cross-Reference Marker Format Source: https://github.com/astoff/digestif/wiki/Tags Specifies the format for cross-reference markers, which allow copying entries from one tags file to another location using a specific URI-like structure. ```text $ref:#//<...>/ ``` -------------------------------- ### Find definition of a LaTeX element Source: https://context7.com/astoff/digestif/llms.txt Uses the find_definition method to locate where a label, citation, or command is defined. It returns an annotated range object containing the position and manuscript context. ```lua local Manuscript = require "digestif.Manuscript" local Cache = require "digestif.Cache" local files = Cache{ ["doc.tex"] = [[ \documentclass{article} \newcommand{\hello}{Hello World} \begin{document} \section{Introduction} \label{sec:intro} See Section~\ref{sec:intro} \hello \end{document} ]] } local script = Manuscript{filename = "doc.tex", format = "latex", files = files} local ref_pos = #[[ \documentclass{article} \newcommand{\hello}{Hello World} \begin{document} \section{Introduction} \label{sec:intro} See Section~\ref{sec:in]] + 1 local definition = script:find_definition(ref_pos) if definition then print(definition.kind) print(definition.pos) print(definition.manuscript.filename) end ``` -------------------------------- ### Cache Manuscript Source: https://github.com/astoff/digestif/wiki/API Retrieves a manuscript object with source at a given path and TeX format. It supports inferring the document root and uses memoization for efficiency. ```APIDOC ## Cache:manuscript(path, format, root_path) ### Description Returns a manuscript object with source at `path` and TeX format `format`. The manuscript belongs to a tree of manuscript objects representing the document to which it belongs. The optional `root_path`, if provided, specifies the root of the document. If omitted, the root is inferred from TeXShop-style magic comment at the beginning of the file. This method uses memoization, so that it is efficient to make repeated calls to it. ### Parameters #### Path Parameters - **path** (string) - Required - The path to the manuscript source file. - **format** (string) - Required - The TeX format of the manuscript. - **root_path** (string) - Optional - The root path of the document. ``` -------------------------------- ### Set INFOPATH Environment Variable (Bash) Source: https://github.com/astoff/digestif/wiki/Common-installation-issues This snippet demonstrates how to export the INFOPATH environment variable in a .bashrc file. It adds a specific directory containing LaTeX info files to the existing INFOPATH, making them accessible to tools like Digestif. ```bash export INFOPATH="/usr/local/texlive/2019/texmf-dist/doc/info:$INFOPATH" ``` -------------------------------- ### Manuscript:find_references(pos) Source: https://context7.com/astoff/digestif/llms.txt Retrieves all references to the item located at the specified position. ```APIDOC ## METHOD Manuscript:find_references(pos) ### Description Lists all references to the item at a given position (label, citation, or command). Useful for "find all references" functionality. ### Method Lua Method Call ### Parameters #### Path Parameters - **pos** (number) - Required - The character position to identify the target item. ### Response #### Success Response - **refs** (table) - A list of annotated ranges, each containing: - **pos** (number): Start position of the reference. - **cont** (number): End position (exclusive). - **manuscript** (table): The manuscript object containing the reference. - **kind** (string): The type of reference. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.