Created
November 2, 2021 10:20
-
-
Save Duologic/ba6dc1df3961811c5f681b596d6f4b28 to your computer and use it in GitHub Desktop.
jsonnet-language-server configuration for vim-lsp, with Tanka support (https://github.com/jdbaldry/jsonnet-language-server/, https://github.com/prabirshrestha/vim-lsp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! GetJsonnetPath() | |
let output=system("tk tool jpath " . shellescape(expand('%'))) | |
if !v:shell_error | |
let $JSONNET_PATH=output | |
call lsp#stop_server('jsonnet-language-server') | |
sleep 100m | |
set filetype=jsonnet | |
endif | |
endfunction | |
augroup jsonnet | |
au! | |
autocmd FileType jsonnet call GetJsonnetPath() | |
augroup END | |
let g:lsp_log_verbose = 1 | |
let g:lsp_log_file = expand('~/vim-lsp.log') | |
if executable('jsonnet-language-server') | |
au User lsp_setup call lsp#register_server({ | |
\ 'name': 'jsonnet-language-server', | |
\ 'cmd': {server_info->['jsonnet-language-server']}, | |
\ 'allowlist': ['jsonnet'], | |
\ }) | |
endif | |
function! s:on_lsp_buffer_enabled() abort | |
setlocal signcolumn=yes | |
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif | |
nmap <buffer> gd <plug>(lsp-definition) | |
nmap <buffer> gS <plug>(lsp-workspace-symbol-search) | |
nmap <buffer> [g <plug>(lsp-previous-diagnostic) | |
nmap <buffer> ]g <plug>(lsp-next-diagnostic) | |
inoremap <buffer> <expr><c-f> lsp#scroll(+4) | |
inoremap <buffer> <expr><c-d> lsp#scroll(-4) | |
endfunction | |
augroup lsp_install | |
au! | |
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment