Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autoload/lsp/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ enddef

# process the 'textDocument/completion' reply from the LSP server
# Result: CompletionItem[] | CompletionList | null
export def CompletionReply(lspserver: dict<any>, cItems: any)
export def CompletionReply(lspserver: dict<any>, cItems: any, trigger_type: number)
lspserver.completeItemsIsIncomplete = false
if cItems->empty()
if lspserver.omniCompletePending
Expand Down Expand Up @@ -182,7 +182,7 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
snippet.CompletionVsnip(items)
endif

if lspOpts.useBufferCompletion
if lspOpts.useBufferCompletion && count(lspOpts.bufferCompletionTriggers, trigger_type) > 0
CompletionFromBuffer(items)
endif

Expand Down Expand Up @@ -549,7 +549,7 @@ def LspComplete()
endif

var [triggerKind, triggerChar] = GetTriggerAttributes(lspserver)
if triggerKind < 0
if count(opt.lspOptions.autoCompleteTriggers, triggerKind) == 0
return
endif

Expand Down
7 changes: 5 additions & 2 deletions autoload/lsp/lspserver.vim
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,11 @@ def GetCompletion(lspserver: dict<any>, triggerKind_arg: number, triggerChar: st
# interface CompletionContext
params.context = {triggerKind: triggerKind_arg, triggerCharacter: triggerChar}

lspserver.rpc_a('textDocument/completion', params,
completion.CompletionReply)
# Wrap CompletionReply, so it gets the trigger kind
var CompletionReplyWithTriggerKind = (lspserverarg: dict<any>, cItems: any) =>
completion.CompletionReply(lspserverarg, cItems, triggerKind_arg)
echom lspserver.completionTriggerChars
lspserver.rpc_a('textDocument/completion', params, CompletionReplyWithTriggerKind)
enddef

# Get lazy properties for a completion item.
Expand Down
17 changes: 17 additions & 0 deletions autoload/lsp/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ export var lspOptions: dict<any> = {
# Otherwise, use omni-completion
autoComplete: true,

# If autoComplete is set to true, limit auto completion to the specified cases:
# 1: typing keyword characters (see :help iskeyword)
# 2: typing a trigger character (language specific, provided by the lsp server.
# E.g., for C++ this might be any of '.', '<', '>', ':', '"', '/', '*'
# Default is to execute autocompletion in both cases. If you want autocompletion only when typing
# a trigger character, set this option to [ 2 ]. You can still use omni-completion to trigger
# completion manually in other situations.
autoCompleteTriggers: [ 1, 2 ],

# In normal mode, highlight the current symbol automatically
autoHighlight: false,

Expand All @@ -25,6 +34,14 @@ export var lspOptions: dict<any> = {
# Automatically populate the location list with new diagnostics
autoPopulateDiags: false,

# If useBufferCompletion is set to true, limit completion to the specified cases:
# 1: typing keyword characters (see :help iskeyword)
# 2: typing a trigger character (language specific, provided by the lsp server.
# E.g., for C++ this might be any of '.', '<', '>', ':', '"', '/', '*'
# Default is to execute buffer completion in both cases. If you do not want buffer completions
# to come up with more specific completions (e.g., class members, file names), set it to [ 1 ].
bufferCompletionTriggers: [ 1, 2 ],

# icase | fuzzy | case match for language servers that replies with a full
# list of completion items
completionMatcher: 'case',
Expand Down