LanguageClient-neovim
LanguageClient-neovim copied to clipboard
Show diagnostics via ALE
Is your feature request related to a problem? Please describe.
This is based on my experience using coc.nvim. I prefer this LSP client (it's purer than coc.nvim and is FZF-friendly), but coc.nvim has some undeniably cool features that I would like to see being ported here. I might help as well if this is out of scope or too difficult to be implemented, even though my Rust knowledge is limited.
One great feature of coc.nvim is being able to display diagnostics via ALE (coc's implementation here). This way, warnings and errors are visually unified and they don't need to override one another.
Describe the solution you'd like
I'll try to be as technical as possible:
ALE has a method called ale#other_source#ShowResults that enables showing results (diagnostics) from another source of information. It receives three arguments: buffer number, source name and a so-called loclist.
According to :h ale-loclist-format, loclist is a dictionary. Here are the relevant fields for this plugin:
text- Required error message.detail- Optional, more descriptive message. If set, it is displayed in place oftextwhenALEDetailis called.lnum- Required, preferably a number, as when a string it gets converted usingstr2nr(). It refers to the error line number. Check docs for more details.col- Optional error column number, default is 0.end_col- Optional end column number, improves error highlights.end_lnum- Optional end line number, it improves multi-line error highlights.filename- Optional filename. Should be an absolute path to the file. Check docs for more details.type- Diagnostic severity. Defaults to'E'.
Describe alternatives you've considered
Using two diagnostics systems, which is inferior to unifying both. For example, I'd rather have only one Lightline extension than two or more.
Additional context
I haven't peeked at the source code yet, so I'm not aware of how difficult it is to implement this feature, nor if it's even relevant for the maintainers. Anyway, I thought it would be a great addition to this plugin as ALE is widely adopted for linting and stuff and it's diagnostics system is pretty robust.
Excellent work so far! Thank you very much.
At least can we have Lint on Save feature instead of Change Throttle ? @autozimu It is more useful for many of us than just linting after a period of time.
A feature like LanguageClient#textDocument_formatting_sync() for diagnostics might be enough. Since we can use autocmd BufWritePre to enable lint before save.