Open ChlorophyII opened 9 months ago
Thanks for the report. To be sure, $HOME/Documents/test.tex
is the file you're currently editing, right?
Thanks for the report. To be sure,
$HOME/Documents/test.tex
is the file you're currently editing, right?
Yes.
I'm still in the process of debugging a similar problem, but digestif
works out-of-the-box with the Emacs builtin tex-mode
but not with auctex. I switched to using a Makefile instead of trying to use the auctex build commands; I'll post the Makefile here when I finish it.
Here's the Makefile:
LATEX := latexmk -interaction=nonstopmode
all: clean-all build
build:
$(LATEX) -shell-escape -f -pdf
clean:
$(LATEX) -c
clean-all:
$(LATEX) -C
I'm no LaTeX whiz; there are probably many situations where this isn't sufficient. However, it works perfectly for the few documents I maintain, including automatic BibTeX and includes of files from subdirectories. The builtin tex-mode
plus digestif
plus this Makefile seems like a better experience than AUCTeX so far.
Confirming experiencing the same problem. Eglot+digestif gives me OP's error in auctex, but not in emacs built-in tex mode.
The problem here is most likely you use AucTeX
, that means that by default major-mode
is something like ConTeXt-mode
rather than context-mode
. Below I am using ConTeXt-mode
as an example, but adjust it to your case be it TeX-mode
or LaTeX-mode
.
If you use eglot it uses major-mode
to figure out and to send language id to the LSP server. In fact you can run something like M-x eglot-events-buffer
and see what it sends to the LSP server. If you use AucTeX
it will send ConTeXt
as a language id and thus LSP server throws an error Invalid LSP language id 'ConTeXt
.
If we look inside langserver.lua
we will see the list of languages it supports
local languageId_translation_table = {
bibtex = "bibtex",
context = "context",
doctex = "doctex",
latex = "latex",
plain = "plain",
plaintex = "plain",
["plain-tex"] = "plain",
tex = "latex", -- this is for vim; maybe "tex" should mean "tex file, undecided format"
texinfo = "texinfo"
}
The problem could be resolved by sending a correct language id to the LSP server. If you are using eglot you are in luck. You can specify a property for the symbol of the major mode you are in like so
(put 'ConTeXt-mode 'eglot-language-id "context")
Now you can reconnect eglot and it should work
@evgeniysharapov In fact, if I go to eglot-events-buffer
I see all my Digestif buffers get the language ID "tex", which seems to be by design, when I look up the definition of eglot--lookup-mode
. So this is a bug in the definiton of eglot-server-programs
.
That said, why do you think this is related to the bug described here?
@ChlorophyII, @skyler544: I can't reproduce this problem, but if you could call M-x eglot-events-buffer
and post the contents here (or send my by email privately) I might be able to understand the issue.
@astoff It could be specific to the eglot
configuration. I have it with default settings and had this issue when used digestif
with AucTeX
. Plain tex-mode
that comes with Emacs works fine. It is not the bug of digestif
and I don't think it's the bug in eglot
either. Perhaps an oddity of AucTeX
. The steps I have described fixed the issue, so I thought I would share it as a workaround
(add-hook 'ConTeXt-mode-hook
(lambda ()
(setq lsp-tex-server 'digestiff)
(put 'ConTeXt-mode 'eglot-language-id "context")
(eglot-ensure))))
I confirm I have the same issue with eglot + digestif. @evgeniysharapov solution doe snot work for me.
@mguzmann Can you post a backtrace? You should get one with M-x toggle-debug-on-error
.
`Debugger entered--Lisp error: (jsonrpc-error "request id=71 failed:" (jsonrpc-error-code . 1) (jsonrpc-error-message . "/home/matias/.digestif/digestif/langserver.lua:34:...") (jsonrpc-error-data)) signal(jsonrpc-error ("request id=71 failed:" (jsonrpc-error-code . 1) (jsonrpc-error-message . "/home/matias/.digestif/digestif/langserver.lua:34:...") (jsonrpc-error-data)))
apply(#
completion-pcm--all-completions("" (prefix "i") #f(compiled-function (probe pred action) #<bytecode 0x1d27e1025dd04780>) nil) completion-substring--all-completions("i" #f(compiled-function (probe pred action) #<bytecode 0x1d27e1025dd04780>) nil 1 completion-flex--make-flex-pattern) completion-flex-all-completions("i" #f(compiled-function (probe pred action) #<bytecode 0x1d27e1025dd04780>) nil 1)
completion--some(#f(compiled-function (style) #<bytecode -0x1b64e8b274eba5bf>) (flex basic fuzzy))
completion--nth-completion(2 "i" #f(compiled-function (probe pred action) #<bytecode 0x1d27e1025dd04780>) nil 1 (metadata (category . eglot) (display-sort-function . #
company-flx-company-capf-advice(#
I am not sure whether it is a corfu problem or a digestif problem, but corfu works fine with other languages, together with Eglot. Here is a minimal config and tex file to reproduce the error. The error appears when corfu tries completion, after typing a few characters.
Error message:
With debug-on-error:
Versions: OS: macOS Sonoma 14.3.1 (23D60) Emacs: 29.2 Corfu: 1.2 Eglot: 1.12.29 digestif: 0.5.1-1
Any insight in how this may be resolved?