Use vim-lsp instead of ale

This commit is contained in:
2021-10-23 15:22:14 +02:00
parent 94788c1147
commit e8d534843d
7 changed files with 59 additions and 22 deletions

17
ale.vim
View File

@@ -1,17 +0,0 @@
" Defines a specific list of linters, that you wish to use for a language
" Install the flake8, python-pylint packages
let g:ale_linters = {
\ 'python': ['flake8', 'pylint'],
\ 'rust': ['rls'],
\}
let g:ale_fixers = {
\ 'python': ['yapf'],
\ 'rust': ['rustfmt']
\}
nmap <F10> :ALEFix<CR>
let g:ale_fix_on_save = 1
let g:airline#extensions#ale#enabled = 1

View File

@@ -70,7 +70,7 @@ source ~/.config/nvim/rainbow.vim
source ~/.config/nvim/neomake.vim
source ~/.config/nvim/keymap.vim
source ~/.config/nvim/timestamp.vim
source ~/.config/nvim/ale.vim
source ~/.config/nvim/html.vim
source ~/.config/nvim/vim-lsp.vim
source ~/.config/nvim/python.vim
source ~/.config/nvim/rust.vim

View File

@@ -23,8 +23,8 @@ noremap <A-t> :belowright split +resize12 term://zsh<CR>
noremap <C-S-d> :bnext <CR> :bd#<CR>
" Map ale wraps to control+k and control+j
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
nmap <silent> <C-k> <Plug>(LspPreviousDiagnostic)
nmap <silent> <C-j> <Plug>(LspNextDiagnostic)
" Map vim-grammarous to <F6>
nmap <F6> :GrammarousCheck <CR>

View File

@@ -15,6 +15,7 @@ Plug 'bling/vim-bufferline'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-commentary'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'lighttiger2505/deoplete-vim-lsp'
Plug 'machakann/vim-highlightedyank'
" Use rainbow parenthesis and automatic closing parens
@@ -22,7 +23,8 @@ Plug 'luochen1990/rainbow'
Plug 'jiangmiao/auto-pairs'
" Linting plugin for multiple languages
Plug 'dense-analysis/ale'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
" Language support for LaTeX
Plug 'vim-latex/vim-latex'

View File

@@ -3,3 +3,12 @@ au BufNewFile,BufRead *.py
\ setlocal foldmethod=indent
\ nospell
" register pyls as a language server.
if executable('pyls')
" pip install python-language-server
au User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'allowlist': ['python'],
\ })
endif

View File

@@ -1,4 +1,11 @@
" No spell checking in code file
autocmd BufNewFile,BufRead *.rs setlocal nospell
if executable('rls')
" pip install rust-language-server
au User lsp_setup call lsp#register_server({
\ 'name': 'rls',
\ 'cmd': {server_info->['rls']},
\ 'allowlist': ['rust'],
\ })
endif

36
vim-lsp.vim Normal file
View File

@@ -0,0 +1,36 @@
" Configure the vim-lsp plugin in order to register any language server.
"
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
" refer to doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
" Set folding
set foldmethod=expr
\ foldexpr=lsp#ui#vim#folding#foldexpr()
\ foldtext=lsp#ui#vim#folding#foldtext()