astoff / digestif

A language server for TeX and friends
Other
264 stars 6 forks source link

ConTeXT support for LMTX installation #54

Closed gour closed 1 year ago

gour commented 1 year ago

Hello,

I've noticed that digestif does work for both eglot and lsp-mode when ConTeXt is installed system-wide via TeXLive package (I'm on Debian Sid), while if I try to use ConteXt via user-installed LMTX it does not offer any auto-completion.

Considering that LMTX is the preferred ConTeXt installation for those not requiring LaTeX since it provides latest version and is much smaller, I wonder what should be configured to make digestif recognize LMTX local ConTeXt installation?

Let me add that I can normally typeset documents by using local installation...

astoff commented 1 year ago

I'm happy to fix this, if you can help me figure out how LMTX finds input files.

Now, first of all, if the command digestif -g context-en.xml succeeds, then all should be working — it does fail for you, right? Second, how did you install Digestif and which Lua interpreter are you using? You might have better luck by using the texlua program shipped by LMTX.

Does kpsewhich -var-brace-value=TEXMF work on LMTX, and if not, what is the proper way to discover the directories where the TeX files are installed? Are there ls-R files in the texmf directories?

gour commented 1 year ago

I'm happy to fix this, if you can help me figure out how LMTX finds input files.

Sure. I'll try...

Now, first of all, if the command digestif -g context-en.xml succeeds, then all should be working — it does fail for you, right?

Correct.

$ digestif -g context-en.xml 
Error: can't find 'context-en.xml' or can't generate tags from it.

Second, how did you install Digestif and which Lua interpreter are you using?

I've installed via self-installing script.

Does kpsewhich -var-brace-value=TEXMF work on LMTX, and if not, what is the proper way to discover the directories where the TeX files are installed?

We actually already discussed this topic back in 2021 - see e.g. this.

Are there ls-R files in the texmf directories?

No, afaict.

So, considering that I've installed lmtx in ~/opt/lmtx if I execute:

$ digestif -g ~/opt/lmtx/tex/texmf-context/tex/context/interface/mkiv/context-en.xml
Generated  context-en.xml.tags with 3759 commands and 351 environments.

that seems to do something, but I wonder what would be the next step?

astoff commented 1 year ago

We actually already discussed this topic back in 2021 - see e.g. this.

Right, but that message doesn't tell me much except that there's some totally new setup involved. And I can't find any documentation.

Are there ls-R files in the texmf directories?

No, afaict.

Okay, then I need to add some extra stuff. It's not just a setting missing...

By the way, do you have a file called ~/opt/lmtx/bin/texlua or similar?

gour commented 1 year ago

By the way, do you have a file called ~/opt/lmtx/bin/texlua or similar?

There is ~/opt/lmtx/tex/texmf-linux-64/bin/luatex, iow.

$ tree ~/opt/lmtx/tex/texmf-linux-64/bin
/home/gour/opt/lmtx/tex/texmf-linux-64/bin
├── context -> luametatex
├── context.lua
├── luametatex
├── luatex
├── mtxrun -> luametatex
└── mtxrun.lua

Also, at the end of LMTX installation I was told to add ~/opt/lmtx/tex/texmf-linux-64/bin to my $PATH...

astoff commented 1 year ago

Okay, I understand the situation now. One more question, though: how are you supposed to install extra packages in LMTX?

gour commented 1 year ago

Okay, I understand the situation now. One more question, though: how are you supposed to install extra packages in LMTX?

You mean "modules"?

I haven't played (yet) with it, but here is some docs.

astoff commented 1 year ago

Could you test if the branch no_kpse works for you? You need to:

  1. Go to the directory digestif is installed and do git pull && git checkout no_kpse.
  2. Go to ~/opt/lmtx/tex/texmf-linux-64/bin and do ln -s luatex texlua
  3. Edit the self-installing script and add the line export DIGESTIF_TEXMF="$HOME/opt/lmtx/tex"
gour commented 1 year ago

Could you test if the branch no_kpse works for you? You need to:

1. Go to the directory digestif is installed and do `git pull && git checkout no_kpse`.

2. Go to ~/opt/lmtx/tex/texmf-linux-64/bin and do `ln -s luatex texlua`

3. Edit the self-installing script and add the line `export DIGESTIF_TEXMF="$HOME/opt/lmtx/tex"`

I've also set DIGESTIF_TEXMF in my (fish) shell's config and running it from cli I get:

$ digestif -g context-en.xml
Generated  context-en.xml.tags with 3759 commands and 351 environments.

but cannot make it work under Emacs - both eglot/lsp-mode?

Any idea?

Eventually, I'd also like to make it work with e.g. Helix editor...

astoff commented 1 year ago

Since you can generate the tags, Digestif must be working. I'll let you figure your configuration, but if you configure your shell then only things you launch from that shell will work. My suggestion was "Edit the self-installing script".

gour commented 1 year ago

Since you can generate the tags, Digestif must be working.

That works only when I have DIGESTIF_TEXMF defined in my shell...I also experience another problem and that is that luatex cmd clashes with the one from TeXLive.

However, when I apt-remove texlive-binaries and run digestif I get:

$ digestif --version
sh: 1: kpsewhich: not found
Digestif 0.5.1-a94dc7a

Why does it still look for kpsewhich ?

My suggestion was "Edit the self-installing script".

I did.

astoff commented 1 year ago

If it's looking for kpsewhich, then it somehow didn't pick up the environment variable configuration.

gour commented 1 year ago

If it's looking for kpsewhich, then it somehow didn't pick up the environment variable configuration.

Even running directly:

$ digestif -g ~/opt/lmtx/tex/texmf-context/tex/context/interface/mkiv/context-en.xml
sh: 1: kpsewhich: not found
/home/gour/.digestif/digestif/util.lua:489: bad argument #1 to 'open' (string expected, got nil)

does not work?

gour commented 1 year ago

If it's looking for kpsewhich, then it somehow didn't pick up the environment variable configuration.

My (foolish) mistake...I just added env var at the very end of the script, so the "main" part of digestif was not able to pick it up. :blush:

Everything is fine now! :sunglasses: