vim: Migrate from ALE and vim-go -> vim-lsp
This commit is contained in:
parent
d404ac9362
commit
f192da86a7
|
@ -1,28 +1,14 @@
|
|||
nmap <silent> gvd <Plug>(go-def-vertical)
|
||||
nmap <silent> gsd <Plug>(go-def-split)
|
||||
nmap <silent> gvD <Plug>(go-def-type-vertical)
|
||||
nmap <silent> gsD <Plug>(go-def-type-split)
|
||||
|
||||
nmap <silent> <leader>gb :up<bar>:GoBuild<cr>
|
||||
nmap <silent> <leader>gr :up<bar>:GoRun<cr>
|
||||
nmap <silent> <leader>gc :GoCallers<cr>
|
||||
" TODO: if GoInfo returns nothing an [INFO] SUCCESS message is shown.
|
||||
" But disabling g:go_echo_command_info impacts build and test workflow.
|
||||
nmap <silent> <leader>gi :GoInfo<cr>
|
||||
nmap <silent> <leader>gp :GoImplements<cr>
|
||||
nmap <silent> <leader>ga :GoAlternate<cr>
|
||||
nmap <silent> <leader>gt :up<bar>:GoTest<cr>
|
||||
nmap <silent> <leader>gf :up<bar>:GoTestFunc<cr>
|
||||
|
||||
nmap <silent> <leader>gk :GoDocBrowser<cr>
|
||||
nmap <silent> <leader>gd :GoDecls<cr>
|
||||
nmap <silent> <leader>gD :GoDeclsDir<cr>
|
||||
" mnemonic: match
|
||||
nmap <silent> <leader>gm :GoSameIds<cr>
|
||||
|
||||
nmap <silent> <leader>gv :vsplit<bar>:GoAlternate!<cr>
|
||||
nmap <silent> <leader>gV <c-w><c-o>:vsplit<bar>:GoAlternate!<cr>
|
||||
nmap <silent> <leader>gs :split<bar>:GoAlternate!<cr>
|
||||
nmap <silent> <leader>gS <c-w><c-o>:split<bar>:GoAlternate!<cr>
|
||||
nmap <silent> <leader>gt <esc>:up<bar>:GoTest<cr>
|
||||
nmap <silent> <leader>gf <esc>:up<bar>:GoTestFunc<cr>
|
||||
nmap <silent> <leader>gat <esc>:GoAddTags<cr>
|
||||
nmap <silent> <leader>grt <esc>:GoRemoveTags<cr>
|
||||
nmap <silent> <leader>gec <esc>:up<bar>:GoErrCheck<cr>
|
||||
|
@ -34,41 +20,23 @@ nnoremap <silent> dq :GoDebugStop<cr>
|
|||
nnoremap <silent> dn :GoDebugNext<cr>
|
||||
nnoremap <silent> ds :GoDebugStep<cr>
|
||||
|
||||
" Avoid window positions jumping around when building and testing:
|
||||
set cmdheight=2
|
||||
|
||||
" fzf configuration:
|
||||
let g:fzf_action = {
|
||||
\ 'ctrl-t': 'tab split',
|
||||
\ 'ctrl-s': 'split',
|
||||
\ 'ctrl-v': 'vsplit' }
|
||||
|
||||
" Vim-Go configuration:
|
||||
let g:go_decls_mode = 'fzf'
|
||||
" Vim-Go configuration
|
||||
let g:go_gopls_enabled = 0
|
||||
let g:go_fmt_autosave = 0
|
||||
" Vim-Go seems to handle fix-on-save better than ALE:
|
||||
" TODO: move to vim-lsp
|
||||
let g:go_imports_autosave = 1
|
||||
let g:go_auto_sameids = 0
|
||||
let g:go_auto_type_info = 0
|
||||
let g:go_info_mode = 'gopls'
|
||||
" ALE handles auto type info:
|
||||
let g:go_auto_type_info = 0
|
||||
let g:go_code_completion_enabled = 1
|
||||
let g:go_code_completion_enabled = 0
|
||||
let g:go_echo_command_info = 0
|
||||
let g:go_echo_go_info = 0
|
||||
let g:go_highlight_diagnostic_errors = 0
|
||||
let g:go_highlight_diagnostic_warnings = 0
|
||||
" g:go_statusline_duration doesn't seem to work accurately, but does help:
|
||||
|
||||
" g:go_statusline_duration doesn't seem to work accurately, but does help
|
||||
" reduce the time the build/test success messages are shown in the status
|
||||
" line.
|
||||
let g:go_statusline_duration = 1000
|
||||
let g:go_gopls_analyses = {
|
||||
\ 'composites': v:false,
|
||||
\ 'unusedparams': v:true,
|
||||
\ 'unusedresult': v:true,
|
||||
\ 'shadow': v:true,
|
||||
\ }
|
||||
let g:go_fmt_options = {
|
||||
\ 'goimports': '-local github.com/sensiblecodeio/cantabular',
|
||||
\ }
|
||||
|
||||
autocmd BufNewFile,BufRead *.go nmap <silent> <leader>g6 :GoAlternate!<cr>
|
||||
|
||||
|
|
167
vimrc
167
vimrc
|
@ -160,6 +160,10 @@ inoremap <expr><C-]> pumvisible() ? "\<C-]>" : "\<Enter>"
|
|||
let g:vim_markdown_conceal = 1
|
||||
|
||||
" fzf configuration:
|
||||
let g:fzf_action = {
|
||||
\ 'ctrl-t': 'tab split',
|
||||
\ 'ctrl-s': 'split',
|
||||
\ 'ctrl-v': 'vsplit' }
|
||||
nmap <leader>t :Files<cr>
|
||||
nmap <leader>T :GFiles<cr>
|
||||
nmap <leader>b :Buffers<cr>
|
||||
|
@ -168,7 +172,29 @@ nmap <leader>gg :Rg<cr>
|
|||
" Lightline configuration:
|
||||
packadd! lightline.vim
|
||||
function! GitHead()
|
||||
return '[' . FugitiveHead() . ']'
|
||||
let l:head = FugitiveHead()
|
||||
if l:head == ''
|
||||
return ''
|
||||
endif
|
||||
return '[' . l:head . ']'
|
||||
endfunction
|
||||
|
||||
function! LightlineLSPErrorText()
|
||||
let l:info = lsp#get_buffer_diagnostics_counts()
|
||||
if info.error == 0
|
||||
return ''
|
||||
endif
|
||||
let sign = get(g:lsp_diagnostics_signs_error, 'text', 'E')
|
||||
return info.error . sign
|
||||
endfunction
|
||||
|
||||
function! LightlineLSPWarningText()
|
||||
let l:info = lsp#get_buffer_diagnostics_counts()
|
||||
if info.warning == 0
|
||||
return ''
|
||||
endif
|
||||
let sign = get(g:lsp_diagnostics_signs_warning, 'text', 'W')
|
||||
return info.warning . sign
|
||||
endfunction
|
||||
|
||||
set laststatus=2
|
||||
|
@ -177,13 +203,21 @@ let g:lightline = {
|
|||
\ 'active': {
|
||||
\ 'left': [ [ 'mode', 'paste' ],
|
||||
\ [ 'readonly', 'filename', 'modified' ],
|
||||
\ [ 'gitbranch' ] ],
|
||||
\ [ 'gitbranch' ], ['lsperror', 'lspwarn'] ],
|
||||
\ 'right': [ ['lineinfo'], ['percent'], ['filetype'], ['gobuild'] ],
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gobuild': 'go#statusline#Show',
|
||||
\ 'gitbranch': 'GitHead',
|
||||
\ },
|
||||
\ 'component_expand': {
|
||||
\ 'lsperror': 'LightlineLSPErrorText',
|
||||
\ 'lspwarn': 'LightlineLSPWarningText',
|
||||
\ },
|
||||
\ 'component_type': {
|
||||
\ 'lsperror': 'error',
|
||||
\ 'lspwarn': 'warning',
|
||||
\ },
|
||||
\ 'mode_map': {
|
||||
\ 'n' : 'N',
|
||||
\ 'i' : 'I',
|
||||
|
@ -220,82 +254,81 @@ let g:echodoc#type='echo'
|
|||
let g:echodoc#enable_at_startup = 1
|
||||
packadd! echodoc.vim
|
||||
|
||||
" ALE configuration:
|
||||
nmap [L <Plug>(ale_first)
|
||||
nmap ]L <Plug>(ale_last)
|
||||
nmap [e <Plug>(ale_previous_wrap_error)
|
||||
nmap ]e <Plug>(ale_next_wrap_error)
|
||||
nmap [w <Plug>(ale_previous_wrap)
|
||||
nmap ]w <Plug>(ale_next_wrap)
|
||||
" vim-fugitive
|
||||
" load before LSP to ensure it doesn't clobber signcolumn
|
||||
packadd! vim-fugitive
|
||||
|
||||
nmap <leader>ad :ALEDetail<cr>
|
||||
map <Leader>g :ALEGoToDefinition<CR>
|
||||
map <Leader>f :ALEFindReferences<CR>
|
||||
map <Leader>fv :ALEFindReferences -vsplit<CR>
|
||||
map <Leader>fh :ALEFindReferences -split<CR>
|
||||
map <Leader>ft :ALEFindReferences -tab<CR>
|
||||
nnoremap gD :ALEGoToTypeDefinition<cr>
|
||||
nnoremap gd :ALEGoToDefinition<cr>
|
||||
command GoToDefinition ALEGoToDefinition
|
||||
command GoToTypeDefinition ALEGoToTypeDefinition
|
||||
command FindReferences ALEFindReferences
|
||||
command Rename ALERename
|
||||
" vim-go
|
||||
" load before LSP to ensure it doesn't clobber mappings
|
||||
packadd! vim-go
|
||||
|
||||
let g:ale_sign_column_always = 1
|
||||
let g:ale_fix_on_save = 1
|
||||
let g:ale_lint_on_text_changed = 1
|
||||
let g:ale_lint_on_enter = 1
|
||||
let g:ale_lint_on_insert_leave = 1
|
||||
let g:ale_lint_on_save = 1
|
||||
let g:ale_echo_cursor = 1
|
||||
let g:ale_lint_delay = 100
|
||||
let g:ale_lsp_suggestions = 1
|
||||
let g:ale_set_balloons = 1
|
||||
" NOTE: Needs https://github.com/dense-analysis/ale/issues/3350
|
||||
let g:ale_rust_analyzer_config = {
|
||||
\ 'diagnostics': { 'disabled': ['unresolved-import'] },
|
||||
\ 'cargo': { 'loadOutDirsFromCheck': v:true },
|
||||
\ 'procMacro': { 'enable': v:true },
|
||||
\ 'checkOnSave': { 'command': 'clippy', 'enable': v:true },
|
||||
\ }
|
||||
let g:ale_go_goimports_options = '-local github.com/sensiblecodeio/cantabular'
|
||||
let g:ale_go_gopls_init_options = {
|
||||
" LSP configuration:
|
||||
packadd! vim-lsp
|
||||
packadd! vim-lsp-settings
|
||||
packadd! deoplete-vim-lsp
|
||||
|
||||
let g:lsp_settings = {
|
||||
\ 'gopls': {
|
||||
\ 'initialization_options': {
|
||||
\ 'ui.diagnostic.analyses': {
|
||||
\ 'composites': v:false,
|
||||
\ 'unusedparams': v:true,
|
||||
\ 'unusedresult': v:true,
|
||||
\ 'shadow': v:true,
|
||||
\ },
|
||||
\ 'staticcheck': v:true}
|
||||
" let g:ale_command_wrapper = 'nice -n5'
|
||||
let g:ale_completion_enabled = 0
|
||||
let g:ale_close_preview_on_insert = 1
|
||||
let g:ale_hover_to_preview = 1
|
||||
let g:ale_history_log_output = 0
|
||||
let g:ale_linters = {
|
||||
\ 'javascript': ['eslint'],
|
||||
\ 'go': ['gopls'],
|
||||
\ 'rust': ['analyzer'],
|
||||
\ 'css': ['stylelint'],
|
||||
\ 'python': ['pyls'],
|
||||
\ 'ruby': ['rubocop'],
|
||||
\ }
|
||||
let g:ale_fixers = {
|
||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||
\ 'javascript': ['prettier'],
|
||||
\ 'rust': [],
|
||||
\ 'go': [],
|
||||
\ 'css': ['stylelint'],
|
||||
\ 'python': ['autopep8'],
|
||||
\ 'ruby': ['rubocop'],
|
||||
\ }
|
||||
\ 'staticcheck': v:true,
|
||||
\ }}}
|
||||
let g:lsp_diagnostics_float_cursor = 1
|
||||
|
||||
function! s:on_lsp_buffer_enabled() abort
|
||||
setlocal omnifunc=lsp#complete
|
||||
setlocal signcolumn=yes
|
||||
|
||||
" Jump to definitions
|
||||
nmap <buffer> gd <plug>(lsp-definition)
|
||||
nmap <buffer> gvd :vertical :LspDefinition<cr>
|
||||
nmap <buffer> gsd :belowright :LspDefinition<cr>
|
||||
nmap <buffer> gD <plug>(lsp-type-definition)
|
||||
nmap <buffer> gvD :vertical :LspTypeDefinition<cr>
|
||||
nmap <buffer> gsD :belowright :LspTypeDefinition<cr>
|
||||
" Map to leader keys too, easy typo:
|
||||
nmap <buffer> <leader>gd <plug>(lsp-definition)
|
||||
nmap <buffer> <leader>gD <plug>(lsp-type-definition)
|
||||
|
||||
" Peek definitions, only on leader keys
|
||||
nmap <buffer> <leader>pd <plug>(lsp-peek-definition)
|
||||
nmap <buffer> <leader>pD <plug>(lsp-peek-type-definition)
|
||||
|
||||
" Navigation
|
||||
nmap <buffer> <silent> ]e <plug>(lsp-next-error)
|
||||
nmap <buffer> <silent> [e <plug>(lsp-previous-error)
|
||||
nmap <buffer> <silent> ]d <plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> <silent> [d <plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> <silent> ]r <plug>(lsp-next-reference)
|
||||
nmap <buffer> <silent> [r <plug>(lsp-previous-reference)
|
||||
|
||||
" Misc actions
|
||||
nmap <buffer> <leader>ci <plug>(lsp-call-hierarchy-incoming)
|
||||
nmap <buffer> <leader>co <plug>(lsp-call-hierarchy-outgoing)
|
||||
nmap <buffer> <leader>a <plug>(lsp-code-action)
|
||||
nmap <buffer> <leader>i <plug>(lsp-implementation)
|
||||
nmap <buffer> <leader>r <plug>(lsp-references)
|
||||
nmap <buffer> <leader>d <plug>(lsp-hover)
|
||||
|
||||
nmap <buffer> <leader>e <plug>(lsp-rename)
|
||||
endfunction
|
||||
|
||||
augroup lsp_install
|
||||
au!
|
||||
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
|
||||
autocmd User lsp_diagnostics_updated call lightline#update()
|
||||
" autocmd BufWritePre <buffer> silent LspDocumentFormatSync
|
||||
" autocmd CursorHold <buffer> silent LspHover
|
||||
augroup END
|
||||
|
||||
" load internal plugins:
|
||||
runtime macros/matchit.vim
|
||||
|
||||
" load ALE only after configured:
|
||||
packadd! ale
|
||||
|
||||
" load other plugins:
|
||||
packadd! tmux-complete.vim
|
||||
packadd! vim-commentary
|
||||
|
@ -303,7 +336,5 @@ packadd! vim-commentary
|
|||
" https://github.com/junegunn/fzf/blob/master/plugin/fzf.vim
|
||||
" and also this separate plugin, which is loaded here:
|
||||
packadd! fzf.vim
|
||||
packadd! vim-go
|
||||
packadd! vim-surround
|
||||
packadd! vim-yaml-folds
|
||||
packadd! vim-fugitive
|
||||
|
|
Loading…
Reference in New Issue