Awesome
vim-lsp + ALE
vim-lsp-ale is a Vim plugin for bridge between vim-lsp and ALE. Diagnostics results received by vim-lsp are shown in ALE's interface.
When simply using ALE and vim-lsp, both plugins run LSP servers respectively. Running multiple server processes consume resources and may cause some issues. And showing lint results from multiple plugins is confusing. vim-lsp-ale solves the problem.
<img alt="screencast" src="https://github.com/rhysd/ss/blob/master/vim-lsp-ale/main.gif?raw=true" width="582" height="316"/>Installation
Install vim-lsp, ale, vim-lsp-ale with your favorite package manager or :packadd
in your .vimrc
.
An example with vim-plug:
Plug 'dense-analysis/ale'
Plug 'prabirshrestha/vim-lsp'
Plug 'rhysd/vim-lsp-ale'
Usage
Register LSP servers you want to use with lsp#register_server
and set vim-lsp
linter to g:ale_linters
for filetypes you want to check with vim-lsp.
The following example configures gopls
to check Go sources.
" LSP configurations for vim-lsp
if executable('gopls')
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': ['gopls'],
\ 'allowlist': ['go', 'gomod'],
\ })
endif
" Set 'vim-lsp' linter
let g:ale_linters = {
\ 'go': ['golint'], " vim-lsp is implicitly active
\ }
This plugin configures vim-lsp and ALE automatically. You don't need to setup various variables.
When opening a source code including some lint errors, vim-lsp will receive the errors from language server and ALE will report the errors in the buffer.
ALE supports also many external programs. All errors can be seen in one place. The above example enables vim-lsp and golint.
For more details, see the documentation.
Testing
There are unit tests and integration tests. CI runs on GitHub Actions. See test/README.md for more details.
License
Licensed under the MIT license.