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 ++++++++-------- diff --git a/autoload/lsp/buffer.vim b/autoload/lsp/buffer.vim index d2ccc8f477643d75c67a0b4335fe51b5afa6016d..64ae27aafe641b1ab64c6a80f1ea366a45bc1e1a 100644 --- a/autoload/lsp/buffer.vim +++ b/autoload/lsp/buffer.vim @@ -4,9 +4,9 @@ # Functions for managing the per-buffer LSP server information 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 @@ endif # LSP server is configured to be a provider for "feature" for lspserver in possibleLSPs - var has_feature = lspserver.features->get(feature, false) + var has_feature: bool = lspserver.features->get(feature, false) if has_feature return lspserver endif @@ -108,7 +108,7 @@ # Return the first LSP server that supports "feature" and doesn't have it # disabled for lspserver in possibleLSPs - if !lspserver.features->has_key(feature) + if lspserver.featureEnabled(feature) return lspserver endif endfor diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index dd902be8705bb9536de098b5ad572d27c885a1ed..7eba712dfbedd87710a4531476074c198dd5d8c1 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -382,8 +382,7 @@ # Notification: textDocument/publishDiagnostics # 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 @@ util.WarnMsg('No more diagnostics found') 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 66e1124cb72edbb0c5af6754397dd6e3528b6e57..fb64674cfc92714b5465561ebcffe868176fc36a 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -508,6 +508,12 @@ maxCount -= 1 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 @@ encodeLocation: function(offset.EncodeLocation, [lspserver]), 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 d6822286d16256b3cc0d66dd743d9c25172a0b4f..ea35c6cf3854dd9a9020e2e33e5c8198c72b8c02 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -11,87 +11,122 @@ # Enable ale diagnostics support. # 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 66a325db7f400095c0800bc97822e5b20e150441..4764c784e4a395014ee92e78ac0f17545f19855d 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 @@ return 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 2967aa32ad786696402733a1129adee7b24aed8e..7d26df82a3f6bc8ab28e2a8e35f5eb48e411a607 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -129,7 +129,7 @@ # If the target buffer is opened in a window in the current tab # 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 f7cb09f875d1c34da941150ede3eed6208735724..c30220b495d7a2ccc6a12ba73d8dc2141f7616c8 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 @@ information. *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 @@ :LspWorkspaceRemoveFolder {folder} 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 ":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 @@ *LspDiagsUpdated* 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.