Files
config.vim9/layers/plug/lsp.vim
2025-12-19 13:14:54 +08:00

35 lines
1.1 KiB
VimL

vim9script
# lsp servers
g:lsp_servers = []
## clangd
const clangd_path = has('win32') || has('win64') ? expand('$SCOOP/apps/clangd/current/bin/clangd.exe') : '/usr/bin/clangd'
if filereadable(clangd_path)
add(g:lsp_servers, { name: 'clangd', filetype: ['c', 'cpp', 'h'], path: clangd_path, args: ['--background-index'] })
endif
## vimlsp
const vimlsp_path = expand("$HOME/.vmr/versions/node_versions/node/bin/vim-language-server")
if filereadable(vimlsp_path)
add(g:lsp_servers, { name: 'vimlsp', filetype: ['vim', 'vimrc'], path: vimlsp_path, args: ['--stdio'] })
endif
# lsp options
g:lsp_options = {
autoHighligntDiags: v:true
}
tui#core#plug#Regist('yegappan/lsp', {
config: () => {
autocmd User LspSetup call LspOptionsSet(g:lsp_options)
autocmd User LspSetup call LspAddServer(g:lsp_servers)
# keymaps
nnoremap <silent> K :LspHover<CR>
if exists('g:which_key_map')
g:which_key_map['v']['o'] = ['LspOutline', 'outline']
else
nnoremap <silent> <Leader>vo :LspOutline<CR>
endif
}
})