valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
764 stars 33 forks source link

Neovim: Skipping text check as LTeX has been disabled for files with code language ID 'tex' via ltex.enabled #278

Open VukanJ opened 11 months ago

VukanJ commented 11 months ago

Describe the bug ltex-ls refuses to check grammar in some latex documents (and reports unexpected errors) while it works fine in main.tex and some other random files which are not the main.tex file.

Steps to reproduce start neovim Install ltex-ls with mason.nvim Create main.tex with minimal setup:

\documentclass{article}
\begin{document}
This documenet is great.
\input{introduction}
\end{document}

A spelling diagnostic appears for "documenet", this is expected. Then create a file introduction.tex and write

\section{intro}
This is the introdcution.

No diagnostic appears despite the typo and the LspLog contains the following errors:

[START][2023-10-17 23:10:50] LSP logging initiated
[ERROR][2023-10-17 23:10:50] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    'SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".\n'
[ERROR][2023-10-17 23:10:50] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    "SLF4J: Defaulting to no-operation (NOP) logger implementation\nSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n"
[ERROR][2023-10-17 23:10:54] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    "Oct 17, 2023 11:10:54 PM org.bsplines.ltexls.server.LtexLanguageServer initialize\nINFO: ltex-ls 16.0.0 - initializing...\n"
[ERROR][2023-10-17 23:10:54] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    "Oct 17, 2023 11:10:54 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment\nFINE: Skipping text check as LTeX has been disabled for files with code language ID 'tex' via ltex.enabled\n"
[ERROR][2023-10-17 23:11:15] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    "Oct 17, 2023 11:11:15 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked\nFINE: Checking the following text in language 'en-US' via LanguageTool: \"\\n\\nThis documenet is great! \"\n"
[ERROR][2023-10-17 23:11:16] .../vim/lsp/rpc.lua:734    "rpc"   "ltex-ls"   "stderr"    "Oct 17, 2023 11:11:16 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment\nFINE: Obtained 1 rule match\n"

Expected behavior

Sample document I use the default setup, no further configuration.

LTeX configuration I do not configure ltex-ls, at all. I just installed it with mason.nvim

LTeX LS log see error messages above

Version information nvim 0.9.4 ltex-ls 16.0.0

Additional context/information

cipollone commented 11 months ago

Same issue. nvim v0.7.2 ltex-ls 16.0.0 JAVA binary and paths correctly set by the ltex-ls script to the release directory

This does not happen with: vim 9.0 coc.nvim ltex-ls

I also see the error about the java logging class

cipollone commented 11 months ago

Solved by setting filetype from plaintex to tex. Also solved by writing let g:tex_flavor = "latex" in ftplugin/tex.vim

VukanJ commented 10 months ago

I can confirm that setting the tex flavor in ftplugin seems to solve the problem of missing diagnostics. Thanks a lot, @cipollone . In my lua settings I added

vim.api.nvim_create_autocmd(
    {
        "BufNewFile",
        "BufRead",
    },
    {
        pattern = "*.tex",
        callback = function()
            vim.opt.filetype = "tex"
        end
    }
)

and under "after/ftplugin/tex.vim" the line you suggested