digestif icon indicating copy to clipboard operation
digestif copied to clipboard

Unable to get digestif to work with ConTeXt LuaMetaTeX (LMTX)

Open 120ace opened this issue 1 year ago • 16 comments
trafficstars

Hello! I have been looking for a context lsp and came across yours. I am very excited to use it; however, I have been unable to get it to work with lmtx. I did some digging and found a similar issue: https://github.com/astoff/digestif/issues/54. I was initially hopeful that this would fix it. It did not. I set DIGESTIF_TEXMF to '~/context/tex' without success. Trying to run 'digestif -g context-en.xml' also failed: I event cd'd to the dir containing it '~/context/tex/texmf-context/tex/context/interface/mkiv' and reran the command. All I get is cannot find or generate tags.

More techical info:

  • I installed digestif using luarocks, v0.5.1
  • I have a texlua.lua at ~/context/tex/texmf-context/scripts/context/lua/texlua.lua
  • lmtx is a standalone user only install

As a sanity check I installed texlive-context and was able to get completions from that. I really do not know what todo further to try and fix this.

120ace avatar Aug 19 '24 05:08 120ace

Try setting DIGESTIF_TEXMF="$HOME/context/tex/texmf-context" (make sure $HOME is expanded to your home directory, a literal ~ will not work).

astoff avatar Aug 20 '24 10:08 astoff

Hi, thanks for the response. Trying that did not fix the problem. Digestif is still telling me Error: can't find 'context-en.xml' or can't generate tags from it. when I run digestif -g context-en.xml. I also tried setting DIGESTIF_TEXMF to "$HOME/context/texmf-context/tex" with no luck there either.

120ace avatar Aug 20 '24 16:08 120ace

Correction "$HOME/context/tex/texmf-context/tex".

120ace avatar Aug 20 '24 16:08 120ace

This should work. What do these commands give you?

find ~/context/ -iname 'context-en.xml'

and

DIGESTIF_TEXMF=$HOME/context/tex/ digestif -v -g context-en.xml

astoff avatar Aug 21 '24 07:08 astoff

Context-en.xml is located at "~/context/tex/texmf-context/tex/context/interface/mkiv/context-en.xml". And "13:12:02 TLPDB not found Error: can't find 'context-en.xml' or can't generate tags from it."

120ace avatar Aug 21 '24 17:08 120ace

With the -v switch you should additionally see a message like Scanned /home/.../context/tex/ in ... ms. If this message is not saying something sensible, then for some reason you didn't manage to supply the environment variable correctly...

astoff avatar Aug 21 '24 17:08 astoff

I set DIGESTIF_TEXMF to "$HOME/context/tex". To make sure that bash expanded it properly I echoed it, it expanded properly. I also reran "digestif -v -g context-en.xml" 2 more times with the same result (aside from the timespamp): "14:09:11 TLPDB not found Error: can't find 'context-en.cml' or can't generate tags from it." Running "digestif -g context-en.xml" without the 'v' flag gives me this: "Error: can't find 'context-en.xml' or can't generate tags from it.". For good measure I exported DIGESTIF_TEXMF. Still got the same result. Could this be because I installed digestif via luarocks? Also, I did not install context via texlive, but as a standalone install.

120ace avatar Aug 21 '24 18:08 120ace

Ah, okay, the luarocks version is somewhat old, that might be the reason then...

In this case I would suggest to use the self-installing script method.

You need to change the line LUA=texlua to LUA=lua (or whatever Lua interpreter you have) and add the line export DIGESTIF_TEXMF=$HOME/context/tex/ to that script.

astoff avatar Aug 21 '24 18:08 astoff

Okay! Will do.

120ace avatar Aug 21 '24 19:08 120ace

Sorry for taking so long to reply. My internet router/modem died on me and I had to wait for a replacement.

I have installed digestif using the self installer script. I set LUA to LUA=lua and added export DIGESTIF_TEXMF="$HOME/context/tex/" to the self installer script. I attempted to run digestif -v -g context-en.xml but was getting this error:

lua5.4: ~/.digestif/digestif/data.lua:1: module 'lfs' not found:
        no field package.preload['lfs']
        no file '~/.digestif/lfs.lua'
        no file '/usr/local/lib/lua/5.4/lfs.so'
        no file '/usr/lib/lua/5.4/lfs.so'
        no file '/usr/local/lib/lua/5.4/loadall.so'
        no file '/usr/lib/lua/5.4/loadall.so'
stack traceback:
        [C]: in function 'require'
        ~/.digestif/digestif/data.lua:1: in main chunk
        [C]: in function 'require'
        ~/.digestif/digestif/langserver.lua:493: in upvalue 'generate'
        ~/.digestif/digestif/langserver.lua:565: in function 'digestif.langserver.main'
        ~/.digestif/bin/digestif:5: in main chunk
        [C]: in ?

I went ahead and installed luafilesystem using luarocks. Rerunning digestif -v -g context-en.xml now gives me:

14:06:46 TLPDB not found
14:06:46 Scanned ~/context/tex/ in 54.248 ms
14:06:46 Generating tags: ~/context/tex/texmf-context/tex/context/interface/mkiv/context-en.xml
14:06:46 Generating tags: ~/context/tex/texmf-context/tex/context/interface/mkiv/context-en.xml
Generated  context-en.xml.tags with 4253 commands and 442 environments.

I proceeded to open a tex file using my editor, but am not getting any auto completions.

Also, following https://github.com/astoff/digestif/wiki/Common-installation-issues#info-nodes, I cannot find any info file in my context installation. Running fd info ~/context results in:

~/context/tex/texmf-context/source/luametatex/source/libraries/pplib/util/utilmeminfo.c
~/context/tex/texmf-context/source/luametatex/source/libraries/pplib/util/utilmeminfo.h
~/context/tex/texmf-context/tex/context/fonts/mkiv/informal-math.lfg
~/context/tex/texmf-context/tex/context/fonts/mkiv/type-imp-informal.mkiv

I am unsure as how to proceed from here. Finally, sorry for not correctly formatting the code snippets in my previous replies. Realized I wasn't using Markdown right.

120ace avatar Aug 28 '24 18:08 120ace

I went ahead and installed luafilesystem using luarocks. Rerunning digestif -v -g context-en.xml now gives me: [...]

Okay this means Digestif is correctly installed now. I guess the rest of the story is editor-specific; you need to convince your editor to run the right program.

I cannot find any info file in my context installation.

This is fine, it's irrelevant for ConTeXt.

astoff avatar Sep 01 '24 09:09 astoff

I was successfully getting Digestif to run inside neovime using nvim-lspconfig and nvim-cmp. IDK why it's not working now. Do you have any suggestions?

120ace avatar Sep 06 '24 04:09 120ace

Clarification: it was running when I was using the texlive context distribution..

120ace avatar Sep 06 '24 06:09 120ace

I cannot find any info file in my context installation.

This is fine, it's irrelevant for ConTeXt.

It seems I’m at the same point somehow.

I’m on macOS Intel, ConTeXt is the LMTX X86 from here, my editor is BBEdit. I’ve installed digestif from the link in the readme.

Running digestif -v -g context-en.xml indicates that everything is fine (I did the modifications similar to the post above, and my output is like shown in that post).

Via BBEdit’s LSP interface, my launch command is digestif, and BBEdit indicates that it is running…

image

and

image

However, it doesn’t seem to “do” anything. E.g., when I remove an opening or closing bracket, I’d expect it to indicate the syntax error.

I have not yet delved into command completion, as I suspect that something fundamental is not working here. Is there any additional launch config needed, e.g. something like --syntax_check=true?

Oh, and when I check the running processes I don’t find any digestif process (the only probably related thing is the BBLSPInterfaceService process). So maybe it isn’t running at all, despite BBEdit’s indicators?

Sorry if I’m missing something obvious, I just started playing around with digestif for the first time today.

tflo avatar Dec 02 '24 11:12 tflo

An update to my post above:

In the meantime I got a new Mac and set it up there again, and it seems to work now. While setting it up, I experimented with variations of the Language ID in BBEdit’s LSP settings and ended up leaving it blank. So I actually don’t know what “fixed” it.

I said “seems to work”, because there is still no syntax check but I now see changes to the completion menu when the server is enabled. So I guess the Features section of the ReadMe has to be taken literally (no mention of syntax checking).

However, in this case, digestif’s completion comes with a huge problem: it seems to partially replace BBEdit’s native completion. (I expected it to add to the completions.)

BBEdit’s native completion draws from (A) the language module (BBLM), from (B) the custom clippings, and also from (C) the word inventory of the current file. A and C are missing when the server is enabled, which means that I lose far more useful completions than are added by digestif, namely because of missing C.

But I guess this is a problem with BBEdit’s implementation, and not with digestif itself.

tflo avatar Dec 09 '24 14:12 tflo

Hey! Sorry for not checking back in. I had forgotten that I left this issue open. I redid my Neovim lsp config a while ago and everything now works flawlessly: autocompletion, popup documentation, and more!

If anyone else is looking into this too, the above mentioned step of setting DIGESTIF_TEXMF to the tex folder of your installed ConTeXt LMTX distribution, which in my case is $HOME/context/tex, works.

If anyone else is also trying to setup Digestif in Nvim, it's dead simple to do so. All you need is to follow the instructions that nvim-lspconfig has laid out for setting up lsp and autocompletion; that's it!

120ace avatar Dec 12 '24 06:12 120ace