| 1 |
Digestif |
| 2 |
======== |
| 3 |
|
| 4 |
<p align="center"> |
| 5 |
<a href="https://github.com/astoff/digestif/actions/workflows/test.yml"><img src="https://github.com/astoff/digestif/actions/workflows/test.yml/badge.svg"></a> |
| 6 |
<a href="https://ctan.org/pkg/digestif"><img alt="CTAN" src="https://img.shields.io/ctan/v/digestif?color=blue"></a> |
| 7 |
<a href="https://luarocks.org/modules/astoff/digestif"><img alt="LuaRocks" src="https://img.shields.io/luarocks/v/astoff/digestif?color=blue"></a> |
| 8 |
</p> |
| 9 |
|
| 10 |
Digestif is a code analyzer, and a [language server][lsp], for LaTeX, |
| 11 |
ConTeXt et caterva. It provides context-sensitive completion, |
| 12 |
documentation, code navigation, and related functionality to any text |
| 13 |
editor that speaks the LSP protocol. |
| 14 |
|
| 15 |
Features |
| 16 |
-------- |
| 17 |
|
| 18 |
- Completion for commands, environments, key-value options (for |
| 19 |
instance, TikZ options), cross-references and citations. |
| 20 |
|
| 21 |
<p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/completion.png"></p> |
| 22 |
|
| 23 |
- Popup help messages, including command signature and documentation. |
| 24 |
For the best results, make sure you have the [LaTeX reference |
| 25 |
manual][latexref] installed as an [info node][info-issues]. |
| 26 |
|
| 27 |
<p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/help.png"></p> |
| 28 |
|
| 29 |
- Find definition and references to labels and citations. |
| 30 |
|
| 31 |
- Document outline. |
| 32 |
|
| 33 |
- Multi-file documents are supported via TeXShop-style magic comments. |
| 34 |
Just add a comment like this near the top of each child document: |
| 35 |
|
| 36 |
``` |
| 37 |
% !TeX root = somefile.tex |
| 38 |
``` |
| 39 |
|
| 40 |
- Digestif is fuzzy! For citations, it tries an exact match against |
| 41 |
the BibTeX identifier and a fuzzy match against author and title. |
| 42 |
In the picture below, the user typed `groalhom`, which matches |
| 43 |
**Gro**thendieck's “Sur quelques points d'**al**gébre |
| 44 |
**hom**ologique”; selecting this inserts the BibTeX identifier |
| 45 |
`Tohoku`. |
| 46 |
|
| 47 |
<p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/cite.png"></p> |
| 48 |
|
| 49 |
Similarly, for cross-references, Digestif tries an exact match |
| 50 |
against the label and a fuzzy match against the text around the |
| 51 |
label. |
| 52 |
|
| 53 |
- Support for LaTeX, ConTeXt, plain TeX, DocTeX (`.dtx` files) and |
| 54 |
Texinfo. |
| 55 |
|
| 56 |
- Bibliography support via BibTeX, BibLaTeX and amsrefs. |
| 57 |
|
| 58 |
- Lua API, independent of the language server protocol, for use in |
| 59 |
editors capable of loading Lua modules. See [API on the wiki][api] |
| 60 |
for details. |
| 61 |
|
| 62 |
Installation |
| 63 |
------------ |
| 64 |
|
| 65 |
Digestif has minimal dependencies and can run on LuaTeX or on a |
| 66 |
standalone Lua interpreter. Correspondingly, there are two ways to |
| 67 |
install it. |
| 68 |
|
| 69 |
### LuaTeX with the self-installing script ![easy] |
| 70 |
|
| 71 |
The only dependencies for this are git and a recent TeX installation. |
| 72 |
|
| 73 |
1. Download the [digestif][self-install-sh] wrapper script (or, on |
| 74 |
Windows, [digestif.cmd][self-install-cmd]). |
| 75 |
2. Place it in your `$PATH` (say, `~/.local/bin`). |
| 76 |
3. Make it executable (`chmod +x ~/.local/bin/digestif`). |
| 77 |
|
| 78 |
In the first run, the script will automatically download the |
| 79 |
package, by default to `~/.digestif`. To update or uninstall, |
| 80 |
simply delete that folder. |
| 81 |
|
| 82 |
### Standalone Lua via LuaRocks |
| 83 |
|
| 84 |
Run `luarocks install digestif`. This should be done either as root |
| 85 |
or with the `--local` option, in which case the executable script will |
| 86 |
land in `~/.luarocks/bin/digestif`; make sure this is in your `$PATH` |
| 87 |
or adapt your text editor configuration accordingly. |
| 88 |
|
| 89 |
Editor setup |
| 90 |
------------ |
| 91 |
|
| 92 |
Next, you need to enable Digestif as a language server in your |
| 93 |
favorite text editor. |
| 94 |
|
| 95 |
### Emacs with the [Eglot] package |
| 96 |
|
| 97 |
Digestif works out-of-the-box with Eglot. Just install the package |
| 98 |
(`M-x package-install RET eglot RET`), open some TeX document and |
| 99 |
enable Eglot (`M-x eglot`). Voilà! Some hints: |
| 100 |
|
| 101 |
- If you want automatic snippet insertion upon choosing a completion |
| 102 |
candidate, make sure to activate `yas-minor-mode` *before* |
| 103 |
starting up Eglot. |
| 104 |
|
| 105 |
- Try the [consult-eglot] package to access the index of a multifile |
| 106 |
project (this is exposed via the the `workspace/symbols` LSP |
| 107 |
method.) |
| 108 |
|
| 109 |
### Emacs with the [lsp-mode] package |
| 110 |
|
| 111 |
To ensure that Digestif is used, add the following to your init file: |
| 112 |
|
| 113 |
``` emacs-lisp |
| 114 |
(setq lsp-tex-server 'digestif) |
| 115 |
``` |
| 116 |
|
| 117 |
### Vim with the [Coc] plugin |
| 118 |
|
| 119 |
See instructions [here](https://github.com/neoclide/coc.nvim/wiki/Language-servers#latex). |
| 120 |
|
| 121 |
### Sublime Text with the [LSP](https://packagecontrol.io/packages/LSP) package |
| 122 |
|
| 123 |
See instructions [here](https://lsp.sublimetext.io/language_servers/#digestif). |
| 124 |
|
| 125 |
### Other editors |
| 126 |
|
| 127 |
It shouldn't be hard to set up other editors to use Digestif. Please |
| 128 |
open an issue if you want to include additional instructions here. |
| 129 |
|
| 130 |
Supported TeX packages |
| 131 |
---------------------- |
| 132 |
|
| 133 |
Digestif tries to learn about the commands provided by a package by |
| 134 |
looking at its source code, but this has limitations, since the |
| 135 |
typical TeX literate documentation is ostensibly not machine readable. |
| 136 |
|
| 137 |
For full support, a detailed “tags” file should be created for each |
| 138 |
package. Among other things, this file lists all defined macros |
| 139 |
together with their signatures and docstrings. To generate a stub |
| 140 |
tags file from a `.sty`, `.cls` or `.dtx` file, use the command |
| 141 |
|
| 142 |
``` |
| 143 |
digestif --generate FILES |
| 144 |
``` |
| 145 |
|
| 146 |
After filling in the missing details, the resulting tags file can be |
| 147 |
added to this repository (pull requests are welcome!). The format of |
| 148 |
the tags files should be more or less self explanatory. See the |
| 149 |
[data](./data) folder for examples. |
| 150 |
|
| 151 |
License |
| 152 |
------- |
| 153 |
|
| 154 |
Digestif is available under the [GNU General Public License][GPL], |
| 155 |
version 3 or later. For some files in the [data](./data) directory, a |
| 156 |
different (free) license applies. See [LICENSE.md](./LICENSE.md) for |
| 157 |
details. |
| 158 |
|
| 159 |
[info-issues]: https://github.com/astoff/digestif/wiki/Common-installation-issues#info-nodes |
| 160 |
[installation-issues]: https://github.com/astoff/digestif/wiki/Common-installation-issues |
| 161 |
[coc]: https://github.com/neoclide/coc.nvim |
| 162 |
[eglot]: https://github.com/joaotavora/eglot |
| 163 |
[latexref]: https://latexref.xyz/ |
| 164 |
[lsp-mode]: https://github.com/emacs-lsp/lsp-mode |
| 165 |
[lsp]: https://microsoft.github.io/language-server-protocol/ |
| 166 |
[api]: https://github.com/astoff/digestif/wiki/API |
| 167 |
[self-install-sh]: https://raw.githubusercontent.com/astoff/digestif/master/scripts/digestif |
| 168 |
[self-install-cmd]: https://raw.githubusercontent.com/astoff/digestif/master/scripts/digestif.cmd |
| 169 |
[easy]: https://raw.githubusercontent.com/astoff/digestif/images/easy.png |
| 170 |
[GPL]: https://www.gnu.org/licenses/gpl-3.0.txt |
| 171 |
[consult-eglot]: https://github.com/mohkale/consult-eglot/ |
| 172 |
[Company mode]: https://company-mode.github.io/ |