From 40645ca294540792504ce3db4cdf84ee45868396 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Wed, 26 Jul 2023 08:14:20 -0700 Subject: [PATCH] When signature help is disabled for a lsp server, don't map the trigger characters. Update the help text to use the space character (32) --- autoload/lsp/buffer.vim | 8 ++++---- autoload/lsp/diag.vim | 7 +++---- autoload/lsp/lspserver.vim | 7 +++++++ autoload/lsp/options.vim | 35 +++++++++++++++++++++++++++++++++++ autoload/lsp/signature.vim | 7 +++++-- autoload/lsp/symbol.vim | 2 +- doc/lsp.txt | 16 ++++++++-------- 7 files changed, 63 insertions(+), 19 deletions(-) diff --git a/autoload/lsp/buffer.vim b/autoload/lsp/buffer.vim index d2ccc8f..64ae27a 100644 --- a/autoload/lsp/buffer.vim +++ b/autoload/lsp/buffer.vim @@ -4,9 +4,9 @@ vim9script import './util.vim' -# A buffer can have one or more attached language servers.  The +# A buffer can have one or more attached language servers. The # "bufnrToServers" Dict contains the list of language servers attached to a -# buffer. The buffer number is the key for the "bufnrToServers" Dict.  The +# buffer. The buffer number is the key for the "bufnrToServers" Dict. The # value is the List of attached language servers. var bufnrToServers: dict>> = {} @@ -99,7 +99,7 @@ export def BufLspServerGet(bnr: number, feature: string = null_string): dictget(feature, false) + var has_feature: bool = lspserver.features->get(feature, false) if has_feature return lspserver endif @@ -108,7 +108,7 @@ export def BufLspServerGet(bnr: number, feature: string = null_string): dicthas_key(feature) + if lspserver.featureEnabled(feature) return lspserver endif endfor diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index dd902be..7eba712 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -382,8 +382,7 @@ enddef # Param: PublishDiagnosticsParams export def DiagNotification(lspserver: dict, uri: string, diags_arg: list>): void # Diagnostics are disabled for this server? - var diagSupported = lspserver.features->get('diagnostics', true) - if !diagSupported + if !lspserver.featureEnabled('diagnostics') return endif @@ -800,8 +799,8 @@ export def LspDiagsJump(which: string, a_count: number = 0): void endif enddef -# Return the sorted diagnostics for buffer "bnr".  Default is the current -# buffer.  A copy of the diagnostics is returned so that the caller can modify +# Return the sorted diagnostics for buffer "bnr". Default is the current +# buffer. A copy of the diagnostics is returned so that the caller can modify # the diagnostics. export def GetDiagsForBuf(bnr: number = bufnr()): list> if !diagsMap->has_key(bnr) || diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 66e1124..fb64674 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -508,6 +508,12 @@ def WaitForResponse(lspserver: dict, req: dict) endwhile enddef +# Returns true when the "lspserver" has "feature" enabled. +# By default, all the features of a lsp server are enabled. +def FeatureEnabled(lspserver: dict, feature: string): bool + return lspserver.features->get(feature, true) +enddef + # Retrieve the Workspace configuration asked by the server. # Request: workspace/configuration def WorkspaceConfigGet(lspserver: dict, configItem: dict): dict @@ -1864,6 +1870,7 @@ export def NewLspServer(serverParams: dict): dict decodeLocation: function(offset.DecodeLocation, [lspserver]), getPosition: function(GetPosition, [lspserver]), getTextDocPosition: function(GetTextDocPosition, [lspserver]), + featureEnabled: function(FeatureEnabled, [lspserver]), textdocDidOpen: function(TextdocDidOpen, [lspserver]), textdocDidClose: function(TextdocDidClose, [lspserver]), textdocDidChange: function(TextdocDidChange, [lspserver]), diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index d682228..ea35c6c 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -11,87 +11,122 @@ export var lspOptions: dict = { # If true, diagnostics will be sent to ale, which will be responsible for # showing them. aleSupport: false, + # In insert mode, complete the current symbol automatically # Otherwise, use omni-completion autoComplete: true, + # In normal mode, highlight the current symbol automatically autoHighlight: false, + # Automatically highlight diagnostics messages from LSP server autoHighlightDiags: true, + # Automatically populate the location list with new diagnostics autoPopulateDiags: false, + # icase | fuzzy | case match for language servers that replies with a full # list of completion items completionMatcher: 'case', + # Due to a bug in the earlier versions of Vim, cannot use the # COMPLETIONMATCHER_CASE constant here for initialization. completionMatcherValue: 1, + # diagnostics signs options diagSignErrorText: 'E>', diagSignHintText: 'H>', diagSignInfoText: 'I>', diagSignWarningText: 'W>', + # In insert mode, echo the current symbol signature in the status line # instead of showing it in a popup echoSignature: false, + # hide disabled code actions hideDisabledCodeActions: false, + # Highlight diagnostics inline highlightDiagInline: true, + # Show the symbol documentation in the preview window instead of in a popup hoverInPreview: false, + # Don't print message when a configured language server is missing. ignoreMissingServer: false, + # Focus on the location list window after ":LspDiag show" keepFocusInDiags: true, + # Focus on the location list window after LspShowReferences keepFocusInReferences: true, + # If true, apply the LSP server supplied text edits after a completion. # If a snippet plugin is going to apply the text edits, then set this to # false to avoid applying the text edits twice. completionTextEdit: true, + # Alignment of virtual diagnostic text, when showDiagWithVirtualText is true # Allowed values: 'above' | 'below' | 'after' (default is 'above') diagVirtualTextAlign: 'above', + # Suppress adding a new line on completion selection with noNewlineInCompletion: false, + # Open outline window on right side outlineOnRight: false, + # Outline window size outlineWinSize: 20, + # Show diagnostic text in a balloon when the mouse is over the diagnostic showDiagInBalloon: true, + # Make diagnostics show in a popup instead of echoing showDiagInPopup: true, + # Suppress diagnostic hover from appearing when the mouse is over the line # Show a diagnostic message on a status line showDiagOnStatusLine: false, + # Show a diagnostic messages using signs showDiagWithSign: true, + # Show a diagnostic messages with virtual text showDiagWithVirtualText: false, + # enable inlay hints showInlayHints: false, + # In insert mode, show the current symbol signature automatically showSignature: true, + # enable snippet completion support snippetSupport: false, + # enable SirVer/ultisnips completion support ultisnipsSupport: false, + # add to autocomplition list current buffer words useBufferCompletion: false, + # Use a floating menu to show the code action menu instead of asking for # input usePopupInCodeAction: false, + # ShowReferences in a quickfix list instead of a location list` useQuickfixForLocations: false, + # enable hrsh7th/vim-vsnip completion support vsnipSupport: false, + # Limit the time autocompletion searches for words in current buffer (in # milliseconds) bufferCompletionTimeout: 100, + # Enable support for custom completion kinds customCompletionKinds: false, + # A dictionary with all completion kinds that you want to customize completionKinds: {} } diff --git a/autoload/lsp/signature.vim b/autoload/lsp/signature.vim index 66a325d..4764c78 100644 --- a/autoload/lsp/signature.vim +++ b/autoload/lsp/signature.vim @@ -8,12 +8,14 @@ import './buffer.vim' as buf # close the signature popup window def CloseSignaturePopup(lspserver: dict) - lspserver.signaturePopup->popup_close() + if lspserver.signaturePopup != -1 + lspserver.signaturePopup->popup_close() + endif lspserver.signaturePopup = -1 enddef def CloseCurBufSignaturePopup() - var lspserver: dict = buf.CurbufGetServer() + var lspserver: dict = buf.CurbufGetServer('signatureHelp') if lspserver->empty() return endif @@ -34,6 +36,7 @@ export def BufferInit(lspserver: dict) endif if !opt.lspOptions.showSignature + || !lspserver.featureEnabled('signatureHelp') # Show signature support is disabled return endif diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index 2967aa3..7d26df8 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -129,7 +129,7 @@ def JumpToWorkspaceSymbol(cmdmods: string, popupID: number, result: number): voi # page, then use it. var winID = fname->bufwinid() if winID == -1 - # not present in the current tab page.  Use the first window. + # not present in the current tab page. Use the first window. winID = winList[0] endif winID->win_gotoid() diff --git a/doc/lsp.txt b/doc/lsp.txt index f7cb09f..c30220b 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -3,7 +3,7 @@ Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) For Vim version 9.0 and above -Last change: June 25, 2023 +Last change: July 26, 2023 ============================================================================== CONTENTS *lsp-contents* @@ -405,7 +405,7 @@ Additionally the following configurations can be made: *lsp-cfg-traceLevel* traceLevel (Optional) set the debug trace level for this language - server.  Supported values are: "off", "debug" and + server. Supported values are: "off", "debug" and "verbose". By default this is seto "off". The language servers are added using the LspAddServer() function. This @@ -1206,7 +1206,7 @@ can map these commands to keys and make it easier to invoke them. Remove a folder from the workspace ============================================================================== -6. Insert mode completion *lsp-ins-mode-completion* +6. Insert Mode Completion *lsp-ins-mode-completion* By default, in insert mode, the LSP plugin automatically displays the matches for the symbol under the cursor in an insert-completion popup menu. You can @@ -1332,7 +1332,7 @@ the current line. The ":LspDiag show" command creates a new location list with the current list of diagnostics for the current buffer. To automatically add the diagnostics messages to the location list, you can set the 'autoPopulateDiags' option to -true.  By default this option is set to false.  When new diagnostics are +true. By default this option is set to false. When new diagnostics are received for a buffer, if a location list with the diagnostics is already present, then it is refreshed with the new diagnostics. @@ -1352,10 +1352,10 @@ message area instead, you can set the 'showDiagInPopup' option to false. By default this is set to true. The lsp#diag#GetDiagsForBuf() function can be used to get all the LSP -diagnostics in a buffer.  This function optionally accepts a buffer number. +diagnostics in a buffer. This function optionally accepts a buffer number. If the buffer number argument is not specified, then the current buffer is -used.  This function returns a |List| of diagnostics sorted by their line and -column number.  Each diagnostic is a |Dict| returned by the language server. +used. This function returns a |List| of diagnostics sorted by their line and +column number. Each diagnostic is a |Dict| returned by the language server. ============================================================================== 8. Tag Function *lsp-tagfunc* @@ -1434,7 +1434,7 @@ LspAttached A |User| autocommand fired when the LSP client LspDiagsUpdated A |User| autocommand invoked when new diagnostics are received from the language server. This is invoked after the LSP client - has processed the diagnostics.  The function + has processed the diagnostics. The function lsp#diag#GetDiagsForBuf() can be used to get all the diagnostics for a buffer. -- 2.44.0