From: Yegappan Lakshmanan Date: Tue, 1 Aug 2023 01:21:50 +0000 (-0700) Subject: Option changes are not handled properly X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=165ec19af8089bdb3701e2a8c061cccd6cc2a871;p=vim-lsp.git Option changes are not handled properly --- diff --git a/autoload/lsp/callhierarchy.vim b/autoload/lsp/callhierarchy.vim index aa2ed40..aca6a55 100644 --- a/autoload/lsp/callhierarchy.vim +++ b/autoload/lsp/callhierarchy.vim @@ -23,7 +23,7 @@ def CallHierarchyTreeItemRefresh(idx: number) if !treeItem->has_key('children') # First time retrieving the children for the item at index "idx" - var lspserver = buf.BufLspServerGet(w:LspBufnr) + var lspserver = buf.BufLspServerGet(w:LspBufnr, 'callHierarchy') if lspserver->empty() || !lspserver.running return endif diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 880e08c..6e24a12 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -100,9 +100,9 @@ export def InitOnce() prop_type_add('LspDiagVirtualTextHint', {highlight: 'LspDiagVirtualTextHint', override: true}) - autocmd_add([{group: 'LspOptionsChanged', + autocmd_add([{group: 'LspCmds', event: 'User', - pattern: '*', + pattern: 'LspOptionsChanged', cmd: 'LspDiagsOptionsChanged()'}]) # ALE plugin support diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 45848c3..726470a 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -16,9 +16,9 @@ export def InitOnce() prop_type_add('LspInlayHintsType', {highlight: 'LspInlayHintsType'}) prop_type_add('LspInlayHintsParam', {highlight: 'LspInlayHintsParam'}) - autocmd_add([{group: 'LspOptionsChanged', + autocmd_add([{group: 'LspCmds', event: 'User', - pattern: '*', + pattern: 'LspOptionsChanged', cmd: 'LspInlayHintsOptionsChanged()'}]) enddef @@ -175,7 +175,8 @@ export def InlayHintsEnable() continue endif for lspserver in lspservers - if !lspserver.featureEnabled('inlayHint') + if !lspserver.ready + || !lspserver.featureEnabled('inlayHint') || (!lspserver.isInlayHintProvider && !lspserver.isClangdInlayHintsProvider) continue diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 77544ff..8c4dbe0 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -322,20 +322,6 @@ export def SwitchSourceHeader() lspserver.switchSourceHeader() enddef -# Show the signature using "textDocument/signatureHelp" LSP method -# Invoked from an insert-mode mapping, so return an empty string. -def g:LspShowSignature(): string - var lspserver: dict = buf.CurbufGetServerChecked('signatureHelp') - if lspserver->empty() - return '' - endif - - # first send all the changes in the current buffer to the LSP server - listener_flush() - lspserver.showSignature() - return '' -enddef - # A buffer is saved. Send the "textDocument/didSave" LSP notification def LspSavedFile(bnr: number) var lspservers: list> = buf.BufLspServersGet(bnr)->filter( @@ -409,8 +395,6 @@ def BufferInit(lspserverId: number, bnr: number): void AddBufLocalAutocmds(lspserver, bnr) diag.BufferInit(lspserver, bnr) - signature.BufferInit(lspserver) - inlayhints.BufferInit(lspserver, bnr) var allServersReady = true var lspservers: list> = buf.BufLspServersGet(bnr) @@ -423,12 +407,23 @@ def BufferInit(lspserverId: number, bnr: number): void if allServersReady for lspsrv in lspservers - # It's only possible to initialize completion when all server capabilities + # It's only possible to initialize the features when the server + # capabilities of all the registered language servers for this file type # are known. var completionServer = buf.BufLspServerGet(bnr, 'completion') if !completionServer->empty() && lspsrv.id == completionServer.id completion.BufferInit(lspsrv, bnr, ftype) endif + + var signatureServer = buf.BufLspServerGet(bnr, 'signatureHelp') + if !signatureServer->empty() && lspsrv.id == signatureServer.id + signature.BufferInit(lspsrv) + endif + + var inlayHintServer = buf.BufLspServerGet(bnr, 'inlayHint') + if !inlayHintServer->empty() && lspsrv.id == inlayHintServer.id + inlayhints.BufferInit(lspsrv, bnr) + endif endfor if exists('#User#LspAttached') diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index eae2093..e791967 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -156,8 +156,8 @@ export def OptionsSet(opts: dict) endif # Apply the changed options - if exists('#LspOptionsChanged#User') - :doautocmd LspOptionsChanged User + if exists('LspCmds##User#LspOptionsChanged') + :doautocmd LspCmds User LspOptionsChanged endif enddef diff --git a/autoload/lsp/signature.vim b/autoload/lsp/signature.vim index 4764c78..0b229b9 100644 --- a/autoload/lsp/signature.vim +++ b/autoload/lsp/signature.vim @@ -23,6 +23,20 @@ def CloseCurBufSignaturePopup() CloseSignaturePopup(lspserver) enddef +# Show the signature using "textDocument/signatureHelp" LSP method +# Invoked from an insert-mode mapping, so return an empty string. +def g:LspShowSignature(): string + var lspserver: dict = buf.CurbufGetServerChecked('signatureHelp') + if lspserver->empty() + return '' + endif + + # first send all the changes in the current buffer to the LSP server + listener_flush() + lspserver.showSignature() + return '' +enddef + export def InitOnce() hlset([{name: 'LspSigActiveParameter', default: true, linksto: 'LineNr'}]) enddef @@ -43,7 +57,7 @@ export def BufferInit(lspserver: dict) # map characters that trigger signature help for ch in lspserver.caps.signatureHelpProvider.triggerCharacters - exe $"inoremap {ch} {ch}=LspShowSignature()" + exe $"inoremap {ch} {ch}=g:LspShowSignature()" endfor # close the signature popup when leaving insert mode