doomemacs
doomemacs copied to clipboard
Latex completion suggestion on whitespace
What did you expect to happen?
After pressing the spacebar, I expect a simple whitespace character typed to the file, nothing more, nothing less.
What actually happened?
After pressing the spacebar, a whitespace character is typed to the file, but a long list of suggestions appear. This happens on every spacebar press and is extrememly annoying.
Describe your attempts to resolve the issue
I am using doom's latex module with +lsp option and texlab as the backend. After disabling +lsp and using plain auctex, there is no issue, but the completion that auctex provides is not as rich as +lsp. I've tested the texlab extension in vscode, it does not exhibit this issue.
Steps to reproduce
- Enable latex in init.el with +lsp option.
- Open any .tex file
- Type a space
System Information
https://pastebin.com/wJX57wpn
What is the value of company-minimum-prefix-length
? You can use SPC h v company-minimum-prefix-length RET
to check it. If it is zero try setting it to a non-zero value.
What is the value of
company-minimum-prefix-length
? You can useSPC h v company-minimum-prefix-length RET
to check it. If it is zero try setting it to a non-zero value.
The variable company-minimum-prefix-length
is set to 2.
The variable
company-minimum-prefix-length
is set to 2.
Sorry can't help you too much as I don't use a latex lsp but does the popup go away if you disable company via M-x company-mode RET
?
The variable
company-minimum-prefix-length
is set to 2.Sorry can't help you too much as I don't use a latex lsp but does the popup go away if you disable company via
M-x company-mode RET
?
Yes, the popup goes away after disabling company-mode. But this also eliminates the good completions.
After some digging around, it seems to be the new yas-snippets integration is interferring with the latex completion and not texlab itself. This issue does not seem to exist for other markup languages like markdown, org, etc. Not sure why company-yassnippets gets triggered by a simple whitespace.
I am having the same issue. As a temporary fix is it possible to get company to not suggest snippets in latex mode?
I did not find the correct way to set the company backends per mode, but you can define yourself a function. Then just execute that in every latex buffer. Ping me if you find a better way to set company-backends for only tex buffers.
(defun fix-latex-company ()
(interactive)
(setq-local company-backends '(company-reftex-labels company-reftex-citations (+latex-symbols-company-backend company-auctex-macros company-auctex-environments) (:separate company-dabbrev company-yasnippet company-ispell))))
One method worked for me was to switch the lsp integration from lsp-mode to eglot.
Perhaps with is a separate bug, but evaluating
(set-company-backend! 'latex-mode '(company-capf company-dabbrev company-yasnippet))
has no effect.
One method worked for me was to switch the lsp integration from lsp-mode to eglot.
Do you have working configuration for texlab
+ eglot
? I have not worked out how to setup the commands textDocument/build
and textDocument/forwardSearch
which I rely on heavily.
One method worked for me was to switch the lsp integration from lsp-mode to eglot.
Do you have working configuration for
texlab
+eglot
? I have not worked out how to setup the commandstextDocument/build
andtextDocument/forwardSearch
which I rely on heavily.
This is what I have for setting eglot to use texlab.
(add-to-list 'eglot-server-programs '((tex-mode bibtex-mode) . ("texlab")))
I'm not sure what textDocument/build
and textDocument/forwardSearch
do. Can you post a link documenting them?
textDocument/build
and textDocument/forwardSearch
are custom messages which can be sent to the language server to compile the tex file and to perform forward search with synctex
. I rely on the textDocument/build
as it integrates very well with tectonic
for compiling tex to pdf, unlike the build methods provided by auctex which I have not managed to get to work.
More information about these "custom messages", including how the client should implement them: https://github.com/latex-lsp/texlab/wiki/LSP-Internals#custom-messages, https://github.com/latex-lsp/texlab/wiki/Previewing
Another useful source is how the lsp-latex
package implements these commands.
https://github.com/ROCKTAKEY/lsp-latex/blob/9200ad19c416b3945d62683dd606917d8a1b3fee/lsp-latex.el#L792-L817
https://github.com/ROCKTAKEY/lsp-latex/blob/9200ad19c416b3945d62683dd606917d8a1b3fee/lsp-latex.el#L823-L887
I think this is a bug of company
and it has been fixed by the upstream. Unpinning company
solves this problem.
;; Adding this to DOOMDIR/packages.el
(unpin! (:completion company))