77 lines
2.8 KiB
VimL
77 lines
2.8 KiB
VimL
""" 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'],
|
|
" \ }
|
|
|
|
if !empty($RUST_VERSION)
|
|
let g:LanguageClient_rustVersion = $RUST_VERSION
|
|
else
|
|
let g:LanguageClient_rustVersion = 'stable'
|
|
endif
|
|
|
|
let g:LanguageClient_serverCommands = {
|
|
"\ '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'],
|
|
\ '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'],
|
|
"\ 'Dockerfile': ['/usr/bin/docker-langserver', '--stdio'],
|
|
\ 'hcl': ['/usr/bin/terraform-ls'],
|
|
\ 'jsonnet': ['/usr/bin/jsonnet-language-server'],
|
|
\ }
|
|
|
|
let g:LanguageClient_rootMarkers = {
|
|
\ 'elm': ['elm.json'],
|
|
\ 'typescript': ['package.json'],
|
|
\ 'typescriptreact': ['package.json'],
|
|
\ 'rust': ['Cargo.toml'],
|
|
\ 'python': ['pyproject.toml', 'setup.cfg'],
|
|
\ 'jsonnet': ['jsonnetfile.json', 'jsonnetfile.lock.json'],
|
|
\ }
|
|
|
|
let g:LanguageClient_hoverPreview = 'always'
|
|
|
|
function LC_maps()
|
|
if has_key(g:LanguageClient_serverCommands, &filetype)
|
|
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)
|
|
|
|
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()
|