vim_config/config/before/language-client.vim

77 lines
2.8 KiB
VimL
Raw Permalink Normal View History

""" 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'],
" \ }
2024-06-22 23:14:37 +02:00
if !empty($RUST_VERSION)
let g:LanguageClient_rustVersion = $RUST_VERSION
else
let g:LanguageClient_rustVersion = 'stable'
endif
let g:LanguageClient_serverCommands = {
2024-06-22 23:14:37 +02:00
"\ 'rust': ['/usr/bin/rustup', 'run', g:LanguageClient_rustVersion, 'rust-analyzer'],
\ 'rust': {
\ 'name': 'rust-analyzer',
\ 'command': ['/usr/bin/rustup', 'run', g:LanguageClient_rustVersion, 'rust-analyzer'],
\ 'initializationOptions': {
\ 'cargo': {
\ 'features': 'true',
\ }
\ },
\ },
\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'],
\ 'elm': ['/usr/bin/elm-language-server'],
2024-06-22 23:15:05 +02:00
\ 'python': ['/usr/bin/pylsp'],
\ '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'],
2024-06-22 23:16:23 +02:00
"\ 'Dockerfile': ['/usr/bin/docker-langserver', '--stdio'],
\ 'hcl': ['/usr/bin/terraform-ls'],
2024-06-22 23:16:04 +02:00
\ 'jsonnet': ['/usr/bin/jsonnet-language-server'],
\ }
let g:LanguageClient_rootMarkers = {
\ 'elm': ['elm.json'],
\ 'typescript': ['package.json'],
\ 'typescriptreact': ['package.json'],
2024-06-22 23:14:37 +02:00
\ 'rust': ['Cargo.toml'],
2024-06-22 23:15:05 +02:00
\ 'python': ['pyproject.toml', 'setup.cfg'],
2024-06-22 23:16:04 +02:00
\ 'jsonnet': ['jsonnetfile.json', 'jsonnetfile.lock.json'],
\ }
let g:LanguageClient_hoverPreview = 'always'
function LC_maps()
if has_key(g:LanguageClient_serverCommands, &filetype)
2022-01-28 15:57:47 +01:00
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
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)
2024-06-22 23:16:23 +02:00
let g:LanguageClient_loggingLevel = 'DEBUG'
let g:LanguageClient_loggingFile = expand('~/.vim/LanguageClient.log')
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
endif
endfunction
autocmd FileType * call LC_maps()