LanguageTool for Efm/diagnosticls

using diagnostic-languageserver on nvim 0.5 with built-in lsp

I have configured it correctly to work with markdownlint, vim-vint & write-good. I am just unable to get it working with languagetool

languagetool = {
                command = "languagetool",
                debounce = 200,
                args = {"-"},
                offsetLine = 0,
                offsetColumn = 0,
                sourceName = "languagetool",
                formatLines = 2,
                formatPattern = {
                    "^\\d+?\\.\\)\\s+Line\\s+(\\d+),\\s+column\\s+(\\d+),\\s+([^\\n]+)\nMessage:\\s+(.*)$",
                    {line = 1, column = 2, message = {4, 3}}
                }
            },

No matter what I do it does not launch. i have changed the args to %file, %text, also commented it out. Could I receive some advice on how to config this differently?

Does not have to be diagnosticls, I actually prefer EFM, but I know diagnosticls has advertised support for languagetool

Also, whats the best way to install languagetool? I have tried installing from the Arch repo. If it is to use the standalone version, or from source, I dont know how to change the above in command section. would it be ā€œjava -jar /path/to/languagetool.jarā€?

This is the last piece of the puzzle for me to config nvim for latex

Is it in your path?

If itā€™s not starting up thereā€™s a chance it canā€™t find the executable.

It is in path. Was installed using pacman, so is in /usr/bin. Is the config I listed correct?

Also, should I try a different installation method?

Donā€™t you need to set filetypes?

of course its set up (for text and tex at the moment).
I just shared the languagetool config related snippet. diagnosticls is working correctly on all other linters and associated filetypes.
My only problem is languagetool

Do you see anything in the logs at ~/.cache/nvim/lsp.log?

i cleared the log to make sure that I read it clean. Opened a filetype registered to this,twice.

Both times it just says

 [ START ] 2021-04-20T13:10:33+0200 ] LSP logging initiated
 [ WARN ] 2021-04-20T13:10:40+0200 ] /usr/share/nvim/runtime/lua/vim/lsp.lua:86 ]    "method textDocument/completion is not supported by any of the servers registered for the current buffer"

So its the config problem in how I define languagetool ? because if it could not find the binary it would perhaps complain in the logs?

@fsouza I just tested it on a large variety of filetypes, and so far, diagnosticsls does launch languagetool but only for text filetypes. Not for markdown, nor for Tex or others. just *.txt files

Even for text files it only launches if the args are not the default ā€œ-ā€ but ā€œ%fileā€

Has anyone gotten it working for Tex? or any other filetype except for txt?

Your suggestion helped me work this out!

When I put ā€˜%fileā€™ for args everything works correctly for markdown files. I attach Lua snippet below.

init_options = {
	linters = {
		languagetool = {
			command = 'languagetool',
			debounce = 200,
			args = { '%file' },
			offsetLine = 0,
			offsetColumn = 0,
			sourceName = 'languagetool',
			formatLines = 2,
			formatPattern = { "^\\d+?\\.\\)\\s+Line\\s+(\\d+),\\s+column\\s+(\\d+),\\s+([^\\n]+)\nMessage:\\s+(.*)$",
				{
					line = 1,
					column = 2,
					message = { 4, 3 }
				}
			},
		}
	},
	filetypes = {
		markdown = 'languagetool'
	}
}

Is it helpful for working with Tex files?

Well the config works for text and markdown but not for Tex.
Also, languagetool for markdown is just ugly as it has problems with lists and other structural properties of markdown.

I have switched over to textidote for both markdown and tex. It recognizes the grammar of the programming language along with the grammar of natural language

Thatā€™s interesting, thanks. Iā€™ll try textidote instantly - I see itā€™s actually powered by languagetool, so thatā€™s great info for me

On this note, Iā€™d really like to see a guide for text/language linting for lspconfig. We can put it on the wiki.

  • ltex-ls (wraps LanguageTool)
  • textidote (wraps LanguageTool)
  • null-ls/nvim-lint with vale
1 Like

well, textidote and languagetool work out of the box with diagnostic-ls. So maybe adding a guide similar to eslint+efm but for textidote+diagnlsticls could work. And documenting/providing-examples for some of the useful args?

I can paste something in this space later.