Compare commits
No commits in common. "f2008af7f7ac68234715b0545c26f5bcd86ceea9" and "152dac0e42bfe35f6573daf38c4ace9ce5741be4" have entirely different histories.
f2008af7f7
...
152dac0e42
2 changed files with 11 additions and 40 deletions
|
@ -131,3 +131,13 @@ 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,47 +162,7 @@ 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()
|
||||||
|
@ -213,6 +173,7 @@ 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