Refactor config loading and change ALE and languageClient configs

This commit is contained in:
sfigato 2022-01-28 12:30:52 +01:00
parent 53f8aa0777
commit e022a99f6d
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
21 changed files with 114 additions and 92 deletions

3
.gitmodules vendored
View File

@ -95,3 +95,6 @@
[submodule "pack/vendor/start/indentLine"]
path = pack/vendor/start/indentLine
url = https://github.com/Yggdroot/indentLine
[submodule "pack/vendor/start/docker-compose.vim"]
path = pack/vendor/start/docker-compose.vim
url = https://github.com/skanehira/docker-compose.vim

View File

@ -10,6 +10,8 @@ sudo pacman -Sy \
mypy \
python-greenlet
echo "Install from AUR: typescript-language-server"
pip3 install --user pynvim
mkdir .{swp,backup,undo}

40
config/after/ale.vim Normal file
View File

@ -0,0 +1,40 @@
function! s:getValaProjectRoot(buffer) abort
let l:cur_path_abs = fnamemodify(a:buffer, ':p:h')
let l:maybe_doap_file = expand(l:cur_path_abs . s:sep . '*.doap')
if !empty(l:maybe_doap_file)
return l:cur_path_abs
endif
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
if filereadable(expand(l:path . '*.doap'))
return l:path
endif
endfor
return ''
endfunction
function! s:curPath(buffer) abort
let l:cur_path = fnamemodify(a:buffer, ':p:h')
return l:cur_path
endfunction
call ale#linter#Define('vala', {
\ 'name': 'vala-language-server',
\ 'lsp': 'stdio',
\ 'output_stream': 'both',
\ 'executable': '/usr/bin/vala-language-server',
\ 'command': '%e',
\ 'project_root': function('s:getValaProjectRoot'),
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})
call ale#linter#Define('promql', {
\ 'name': 'promql-langserver',
\ 'lsp': 'stdio',
\ 'output_stream': 'both',
\ 'executable': '/usr/local/bin/promql-langserver',
\ 'command': '%e',
\ 'project_root': function('s:curPath'),
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View File

@ -45,49 +45,6 @@ let g:ale_fixers = {
\ 'scss': ['prettier'],
\}
function! s:getValaProjectRoot(buffer) abort
let l:cur_path_abs = fnamemodify(a:buffer, ':p:h')
let l:maybe_doap_file = expand(l:cur_path_abs . s:sep . '*.doap')
if !empty(l:maybe_doap_file)
return l:cur_path_abs
endif
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
if filereadable(expand(l:path . '*.doap'))
return l:path
endif
endfor
return ''
endfunction
function! s:curPath(buffer) abort
let l:cur_path = fnamemodify(a:buffer, ':p:h')
return l:cur_path
endfunction
packloadall
call ale#linter#Define('vala', {
\ 'name': 'vala-language-server',
\ 'lsp': 'stdio',
\ 'output_stream': 'both',
\ 'executable': '/usr/bin/vala-language-server',
\ 'command': '%e',
\ 'project_root': function('s:getValaProjectRoot'),
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})
call ale#linter#Define('promql', {
\ 'name': 'promql-langserver',
\ 'lsp': 'stdio',
\ 'output_stream': 'both',
\ 'executable': '/usr/local/bin/promql-langserver',
\ 'command': '%e',
\ 'project_root': function('s:curPath'),
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})
let g:ale_rust_rls_config = {
\ 'rust': {
\ 'clippy_preference': 'on'
@ -117,5 +74,3 @@ let g:ale_fix_on_save = 1
let g:ale_hover_to_preview = 1
let g:ale_float_preview = 1
let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰']
packloadall

View File

@ -0,0 +1,52 @@
""" LanguageClient
" Required for operations modifying multiple buffers like rename.
set hidden
" let g:LanguageClient_serverCommands = {
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
let g:LanguageClient_serverCommands = {
\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'],
\ 'elm': ['/usr/bin/elm-language-server'],
\ 'python': ['/usr/bin/pyls'],
\ 'go': ['/usr/bin/gopls'],
\ 'promql': ['/usr/local/bin/promql-langserver'],
\ 'java': ['/usr/bin/java-language-server'],
\ 'typescript': ['/usr/bin/typescript-language-server', '--stdio'],
\ 'typescriptreact': ['/usr/bin/typescript-language-server', '--stdio'],
\ }
let g:LanguageClient_rootMarkers = {
\ 'elm': ['elm.json'],
\ 'typescript': ['package.json'],
\ 'typescriptreact': ['package.json'],
\ }
let g:LanguageClient_hoverPreview = 'always'
let g:LanguageClient_loggingFile = expand('~/.vim/LanguageClient.log')
function LC_maps()
if has_key(g:LanguageClient_serverCommands, &filetype)
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gdd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gdi :call LanguageClient#textDocument_implementation()<CR>
nnoremap <silent> gdt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <silent> gds :call LanguageClient#textDocument_documentSymbol()<CR>
nnoremap <silent> gdr :call LanguageClient#textDocument_references()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
" noremap <F5> <Plug>(lcn-menu)
" noremap <buffer> <silent> K <Plug>(lcn-hover)
" noremap <buffer> <silent> gd <Plug>(lcn-definition)
" noremap <buffer> <silent> <F2> <Plug>(lcn-rename)
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
endif
endfunction
autocmd FileType * call LC_maps()

View File

@ -1,34 +0,0 @@
""" LanguageClient
" Required for operations modifying multiple buffers like rename.
set hidden
" let g:LanguageClient_serverCommands = {
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
let g:LanguageClient_serverCommands = {
\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'],
\ 'elm': ['/usr/bin/elm-language-server'],
\ 'python': ['/usr/bin/pyls'],
\ 'go': ['/usr/bin/gopls'],
\ 'promql': ['/usr/local/bin/promql-langserver'],
\ 'java': ['/usr/bin/java-language-server']
\ }
let g:LanguageClient_rootMarkers = {
\ 'elm': ['elm.json'],
\ }
let g:LanguageClient_hoverPreview = 'always'
" note that if you are using Plug mapping you should not use `noremap` mappings.
nmap <F5> <Plug>(lcn-menu)
" Or map each action separately
nmap <silent>K <Plug>(lcn-hover)
nmap <silent> gd <Plug>(lcn-definition)
nmap <silent> <F2> <Plug>(lcn-rename)

@ -0,0 +1 @@
Subproject commit 8a6dbc869200f11d00f532e6bee8f2e7ce4ef64e

29
vimrc
View File

@ -17,17 +17,21 @@ let g:python_host_prog='/usr/bin/python'
""" source
" all other includes are in alphabetical order
source $VIMHOME/config/ale.vim
source $VIMHOME/config/fzf.vim
source $VIMHOME/config/indent.vim
source $VIMHOME/config/language-client.vim
source $VIMHOME/config/mucomplete.vim
source $VIMHOME/config/nerdtree.vim
source $VIMHOME/config/powerline.vim
source $VIMHOME/config/rg.vim
source $VIMHOME/config/theme.vim " this sets the colorscheme
source $VIMHOME/config/vim-go.vim
source $VIMHOME/config/vim-rooter.vim
source $VIMHOME/config/before/ale.vim
source $VIMHOME/config/before/fzf.vim
source $VIMHOME/config/before/indent.vim
source $VIMHOME/config/before/language-client.vim
source $VIMHOME/config/before/mucomplete.vim
source $VIMHOME/config/before/nerdtree.vim
source $VIMHOME/config/before/powerline.vim
source $VIMHOME/config/before/rg.vim
source $VIMHOME/config/before/theme.vim " this sets the colorscheme
source $VIMHOME/config/before/vim-go.vim
source $VIMHOME/config/before/vim-rooter.vim
packloadall
source $VIMHOME/config/after/ale.vim
""" general
@ -37,8 +41,6 @@ set nospell
" au VimLeave * :!clear
syntax on
packloadall
silent! helptags ALL
" Enable persistent undo
@ -153,6 +155,7 @@ nnoremap <C-p> :FZF<CR>
nnoremap <leader>f :Buffers<CR>
nnoremap <C-F> :Files<CR>
nnoremap <C-\> :Rg<CR>
nnoremap <leader>k :exe "Rg " . expand("<cword>")<cr>
nnoremap <leader>s :call Fzf_dev()<CR>
nnoremap <leader>c :Commits<CR>
nnoremap <leader>b :Git blame<CR>