This repository was archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
filetype specific loading of LSs with sensible maps #1
Copy link
Copy link
Closed
Description
Maybe this repo could make the whole setup more filetype specific and add sensible default mappings for these?
A list of LSs is given in the wiki and the setup usually only prescribes a name, filetype and exe path, sporadically with some args such as --stdio, say
if executable('neocmakelsp')
g:lspServers->add({
name: 'cmake',
filetype: ['cmake'],
path: 'neocmakelsp',
args: ['--stdio'],
})As one can end up on a computer without the LS, an initial check for each file type
if !exists('g:lspFiletypes') | finish | endif
if index(g:lspFiletypes, &filetype) == -1 | finish | endifcan avoid setting options and mappings such as, let's take ftplugin/c.vim,
setlocal keywordprg=:LspHover
setlocal formatexpr=lsp#lsp#FormatExpr()
setlocal tagfunc=lsp#lsp#TagFunc
inoremap <buffer> <c-s> <cmd>LspShowSignature<CR>
nnoremap <buffer> <c-s> <cmd>LspShowSignature<CR>
nnoremap <buffer> gd <cmd>LspPeekDeclaration<CR>
nnoremap <buffer> gD <cmd>LspGotoDeclaration<CR>
nnoremap <buffer> g] <cmd>LspPeekDefinition<CR>
nnoremap <buffer> m, <cmd>LspDiag show<cr>
nnoremap <buffer> m. <cmd>LspDiag current<cr>
nnoremap <buffer> m[ <cmd>LspDiag prev<cr>
nnoremap <buffer> m] <cmd>LspDiag next<cr>
nnoremap <buffer> m{ <cmd>LspDiag first<cr>
nnoremap <buffer> m} <cmd>LspDiag last<cr>
nnoremap <buffer> g6 <cmd>LspSwitchSourceHeader<CR>
nnoremap <buffer> <F2> <cmd>LspRename<CR>
nnoremap <buffer><expr> do &l:diff ? 'do' : '<cmd>LspCodeLens<CR>'
nnoremap <buffer> dO <cmd>LspCodeAction<cr>
xnoremap <buffer> gw <cmd>LspFormat<cr>
nnoremap <buffer> gw <plug>(LspFormat)
onoremap <buffer> <SID>(underline) _
nmap <buffer><expr> gww 'gw' . v:count1 . '<SID>(underline)'
nnoremap <buffer> z* <cmd>LspSymbolSearch<CR>
nnoremap <buffer> m* <cmd>LspHighlight<CR>
nnoremap <buffer> cod <cmd>LspDiag highlight toggle<cr>
nnoremap <buffer> coh :<c-u>LspInlayHints toggle<cr>
xnoremap <buffer> V <cmd>LspSelectionExpand<cr>
xnoremap <buffer> v <cmd>LspSelectionShrink<cr>in this case.
Metadata
Metadata
Assignees
Labels
No labels