endfor
enddef
+# add completion from current buf
+def CompletionFromBuffer(items: list<dict<any>>)
+ var words = {}
+ for line in getline(1, '$')
+ for word in line->split('\W\+')
+ if !has_key(words, word) && len(word) > 1
+ words[word] = 1
+ items->add({
+ label: word,
+ data: {
+ entryNames: [word],
+ },
+ kind: 26,
+ documentation: "",
+ })
+ endif
+ endfor
+ endfor
+enddef
+
# process the 'textDocument/completion' reply from the LSP server
# Result: CompletionItem[] | CompletionList | null
export def CompletionReply(lspserver: dict<any>, cItems: any)
endif
if opt.lspOptions.useBufferCompletion
- # add completion from current buf
- var words = {}
- var text = join(getline(1, '$'), "\n")
- for word in split(text, '\W\+')
- if !has_key(words, word) && len(word) > 1
- words[word] = 1
- items->add({
- label: word,
- data: {
- entryNames: [word],
- },
- kind: 26,
- documentation: "",
- })
- endif
- endfor
+ CompletionFromBuffer(items)
endif
var completeItems: list<dict<any>> = []
line, use a popup menu instead of echoing.
By default this is set to false.
*lsp-opt-useBufferCompletion*
-useBufferCompletion |Boolean| option. If enable adds current buffer words
- to autocompletion list. Мay degrade vim performance.
+useBufferCompletion |Boolean| option. If enabled, the words from the current
+ buffer are added to the auto completion list. This may degrade Vim performance
+ as the current buffer contents are processed every time the completion
+ menu is displayed.
By default this is set to false.
For example, to disable the automatic placement of signs for the LSP