Compare commits
2 commits
152dac0e42
...
f2008af7f7
Author | SHA1 | Date | |
---|---|---|---|
f2008af7f7 | |||
e27b22b51f |
2 changed files with 40 additions and 11 deletions
|
@ -131,13 +131,3 @@ statusline.Init()
|
||||||
# necessary.
|
# necessary.
|
||||||
import "./lsp.vim"
|
import "./lsp.vim"
|
||||||
lsp.Configure()
|
lsp.Configure()
|
||||||
|
|
||||||
set formatexpr=lsp#lsp#FormatExpr()
|
|
||||||
set keywordprg=:LspHover
|
|
||||||
nnoremap gD <Cmd>LspGotoDeclaration<CR>
|
|
||||||
nnoremap gd <Cmd>LspGotoDefinition<CR>
|
|
||||||
nnoremap gi <Cmd>LspGotoImpl<CR>
|
|
||||||
nnoremap <C-k> <Cmd>LspShowSignature<CR>
|
|
||||||
nnoremap gr <Cmd>LspShowReferences<CR>
|
|
||||||
xnoremap <silent> <Leader>e <Cmd>LspSelectionExpand<CR>
|
|
||||||
xnoremap <silent> <Leader>s <Cmd>LspSelectionShrink<CR>
|
|
||||||
|
|
|
@ -162,7 +162,47 @@ def ListMissingServers(argLead: string, cmdLine: string, cursorPos: number): lis
|
||||||
return MissingServers()->mapnew((_, server): string => server.name)
|
return MissingServers()->mapnew((_, server): string => server.name)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def ServerHas(feature: string): bool
|
||||||
|
return lsp#buffer#CurbufGetServer(feature) != {}
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def LspBufferSettings(): void
|
||||||
|
if ServerHas('documentFormatting')
|
||||||
|
setlocal formatexpr=lsp#lsp#FormatExpr()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('hover')
|
||||||
|
setlocal keywordprg=:LspHover
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('declaration')
|
||||||
|
nnoremap <buffer> gD <Cmd>LspGotoDeclaration<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('definition')
|
||||||
|
nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('implementation')
|
||||||
|
nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('references')
|
||||||
|
nnoremap <buffer> gr <Cmd>LspShowReferences<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ServerHas('selectionRange')
|
||||||
|
xnoremap <buffer> <silent> <Leader>e <Cmd>LspSelectionExpand<CR>
|
||||||
|
xnoremap <buffer> <silent> <Leader>s <Cmd>LspSelectionShrink<CR>
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
|
|
||||||
export def Configure(): void
|
export def Configure(): void
|
||||||
|
augroup dot/vim/lsp.vim
|
||||||
|
autocmd!
|
||||||
|
autocmd User LspAttached LspBufferSettings()
|
||||||
|
augroup END
|
||||||
|
|
||||||
# We have to use final rather than const because LspAddServer() assumes it can
|
# We have to use final rather than const because LspAddServer() assumes it can
|
||||||
# modify the dicts it gets, rather than making a fresh copy to mess with.
|
# modify the dicts it gets, rather than making a fresh copy to mess with.
|
||||||
final installedServers = InstalledServers()
|
final installedServers = InstalledServers()
|
||||||
|
@ -173,7 +213,6 @@ export def Configure(): void
|
||||||
const missingCount = len(lspServers) - len(installedServers)
|
const missingCount = len(lspServers) - len(installedServers)
|
||||||
const warn = $'{missingCount} language server{missingCount > 1 ? "s are" : " is"} configured, but not installed. You may want to run :LspInstall.'
|
const warn = $'{missingCount} language server{missingCount > 1 ? "s are" : " is"} configured, but not installed. You may want to run :LspInstall.'
|
||||||
augroup dot/vim/lsp.vim
|
augroup dot/vim/lsp.vim
|
||||||
autocmd!
|
|
||||||
exe $'autocmd VimEnter * ++once echo {strings.Quote(warn)}'
|
exe $'autocmd VimEnter * ++once echo {strings.Quote(warn)}'
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue