null-ls.nvim icon indicating copy to clipboard operation
null-ls.nvim copied to clipboard

diagnostics: add LanguageTool support (by ltrs)

Open fcsonline opened this issue 2 years ago • 8 comments

Adding support for LanguageTool. LanguageTool is an online service to help you to correct blocks of text. It is a writing assistant, quite similar to other services like Grammarly.

More info: https://languagetool.org/

I think it can be handy to have an integration in NeoVim to help people to write better documentation, commit messages, etc.

This integration is performed thanks to languagetool-rust. A Rust implementation that interact with LanguageTool API.

This Null-ls Builtin adds diagnostics and code actions capabilities.

Some screenshots:

image image

fcsonline avatar Aug 08 '22 14:08 fcsonline

Awesome!

masylum avatar Aug 08 '22 15:08 masylum

Looks great! I'll have a chance to test this later in the week and will give more detailed feedback then.

jose-elias-alvarez avatar Aug 08 '22 17:08 jose-elias-alvarez

LTRS maintainer here. Do you know if Null-ls has a way to take care of starting and stopping the server it uses? I am currently working on an integration with Docker and I might design my interface based on that response :)

jeertmans avatar Aug 09 '22 19:08 jeertmans

@jeertmans The current architecture of null-ls assumes that each run of a command is self-contained, so the status quo is ideal from our point of view. It would be pretty simple to add hooks that run before a command's first run or upon exiting, but anything more complicated than that (e.g. continuous communication via stdio) would be tricky.

I hope you don't let that constrain the design of LTRS, though! null-ls is ultimately meant to cover gaps in the ecosystem, so if you want to go in a different direction, please feel free to do so.

jose-elias-alvarez avatar Aug 09 '22 20:08 jose-elias-alvarez

Thank you @jose-elias-alvarez ! This will definitely not constraint the design :-) Are those possible hooks directly included into null-ls, or to be set up separately?

jeertmans avatar Aug 09 '22 21:08 jeertmans

Are those possible hooks directly included into null-ls, or to be set up separately?

Not implemented yet, but it would be pretty easy to add in the ability to run an arbitrary Lua function on start / stop!

jose-elias-alvarez avatar Aug 09 '22 23:08 jose-elias-alvarez

I tested this out and it works well, though there's a noticeable delay when requesting code actions. #915 deals with a similar issue with cspell by re-using the diagnostics generated by the diagnostics source instead of spawning a new process. This has the downside of making the code action source dependent on the diagnostics source, but it should be safe to assume that users will want to use them together.

What do you think? I'm also OK merging this as-is for now and seeing if we can incorporate potential future changes later on.

jose-elias-alvarez avatar Aug 11 '22 14:08 jose-elias-alvarez

Awesome! Right now I'm a bit busy to implement this improvement. If you are ok with the current code, merge it and I'll work as soon as I have more free time. 👌

fcsonline avatar Aug 13 '22 07:08 fcsonline

Any update on this @jose-elias-alvarez ?

jeertmans avatar Oct 05 '22 10:10 jeertmans

This should be good to merge for now, we can investigate performance improvements in the future. Thanks!

jose-elias-alvarez avatar Oct 06 '22 14:10 jose-elias-alvarez