diff --git a/dot-config/vim/init.vim b/dot-config/vim/init.vim index e625c12..1362504 100644 --- a/dot-config/vim/init.vim +++ b/dot-config/vim/init.vim @@ -131,13 +131,3 @@ statusline.Init() # necessary. import "./lsp.vim" lsp.Configure() - -set formatexpr=lsp#lsp#FormatExpr() -set keywordprg=:LspHover -nnoremap gD LspGotoDeclaration -nnoremap gd LspGotoDefinition -nnoremap gi LspGotoImpl -nnoremap LspShowSignature -nnoremap gr LspShowReferences -xnoremap e LspSelectionExpand -xnoremap s LspSelectionShrink diff --git a/dot-config/vim/lsp.vim b/dot-config/vim/lsp.vim index 447c1e1..cee3e52 100644 --- a/dot-config/vim/lsp.vim +++ b/dot-config/vim/lsp.vim @@ -162,7 +162,24 @@ def ListMissingServers(argLead: string, cmdLine: string, cursorPos: number): lis return MissingServers()->mapnew((_, server): string => server.name) enddef +def LspBufferSettings(): void + setlocal formatexpr=lsp#lsp#FormatExpr() + setlocal keywordprg=:LspHover + nnoremap gD LspGotoDeclaration + nnoremap gd LspGotoDefinition + nnoremap gi LspGotoImpl + nnoremap LspShowSignature + nnoremap gr LspShowReferences + xnoremap e LspSelectionExpand + xnoremap s LspSelectionShrink +enddef + 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 # modify the dicts it gets, rather than making a fresh copy to mess with. final installedServers = InstalledServers() @@ -173,7 +190,6 @@ export def Configure(): void 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.' augroup dot/vim/lsp.vim - autocmd! exe $'autocmd VimEnter * ++once echo {strings.Quote(warn)}' augroup END endif