Skip to content

Commit

Permalink
When signature help is disabled for a lsp server, don't map the trigg…
Browse files Browse the repository at this point in the history
…er characters. Update the help text to use the space character (32)
  • Loading branch information
yegappan committed Jul 26, 2023
1 parent c607704 commit 40645ca
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 19 deletions.
8 changes: 4 additions & 4 deletions autoload/lsp/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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<list<dict<any>>> = {}

Expand Down Expand Up @@ -99,7 +99,7 @@ export def BufLspServerGet(bnr: number, feature: string = null_string): dict<any

# 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
Expand All @@ -108,7 +108,7 @@ export def BufLspServerGet(bnr: number, feature: string = null_string): dict<any
# 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
Expand Down
7 changes: 3 additions & 4 deletions autoload/lsp/diag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ enddef
# Param: PublishDiagnosticsParams
export def DiagNotification(lspserver: dict<any>, uri: string, diags_arg: list<dict<any>>): void
# Diagnostics are disabled for this server?
var diagSupported = lspserver.features->get('diagnostics', true)
if !diagSupported
if !lspserver.featureEnabled('diagnostics')
return
endif

Expand Down Expand Up @@ -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<dict<any>>
if !diagsMap->has_key(bnr) ||
Expand Down
7 changes: 7 additions & 0 deletions autoload/lsp/lspserver.vim
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ def WaitForResponse(lspserver: dict<any>, req: dict<any>)
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<any>, 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<any>, configItem: dict<any>): dict<any>
Expand Down Expand Up @@ -1864,6 +1870,7 @@ export def NewLspServer(serverParams: dict<any>): dict<any>
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]),
Expand Down
35 changes: 35 additions & 0 deletions autoload/lsp/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,87 +11,122 @@ export var lspOptions: dict<any> = {
# 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 <CR>
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: {}
}
Expand Down
7 changes: 5 additions & 2 deletions autoload/lsp/signature.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import './buffer.vim' as buf

# close the signature popup window
def CloseSignaturePopup(lspserver: dict<any>)
lspserver.signaturePopup->popup_close()
if lspserver.signaturePopup != -1
lspserver.signaturePopup->popup_close()
endif
lspserver.signaturePopup = -1
enddef

def CloseCurBufSignaturePopup()
var lspserver: dict<any> = buf.CurbufGetServer()
var lspserver: dict<any> = buf.CurbufGetServer('signatureHelp')
if lspserver->empty()
return
endif
Expand All @@ -34,6 +36,7 @@ export def BufferInit(lspserver: dict<any>)
endif

if !opt.lspOptions.showSignature
|| !lspserver.featureEnabled('signatureHelp')
# Show signature support is disabled
return
endif
Expand Down
2 changes: 1 addition & 1 deletion autoload/lsp/symbol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions doc/lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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*
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 40645ca

Please sign in to comment.