autoload/lsp/completion.vim | 34 ++++++++++++++++++---------------- autoload/lsp/options.vim | 2 ++ doc/lsp.txt | 4 ++++ diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 77e24867f3644f9d5505d5fa0b22728624072cde..607d78d52e69fdcfc3155f3daa3330f05cd24357 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -172,22 +172,24 @@ if opt.lspOptions.ultisnipsSupport CompletionUltiSnips(prefix, items) endif - # 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 + 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 + endif var completeItems: list> = [] for item in items diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index ef708ee09dcc3cc2a57fd9d7bf72263498a23ae6..8e29c79e2ae39a0832b7ea49cac7359f601d8242 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -67,6 +67,8 @@ # 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, + # add to autocomplition list current buffer words + useBufferCompletion: false, # Enable support for custom completion kinds customCompletionKinds: false, # A dictionary with all completion kinds that you want to customize diff --git a/doc/lsp.txt b/doc/lsp.txt index 5edad1cee1fd701a2989c049ba101fbf1d926250..ef60be1226c974b53e1fb20e442de7826826bb9a 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -498,6 +498,10 @@ usePopupInCodeAction |Boolean| option. When using the |:LspCodeAction| command to display the code action for the current 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. + By default this is set to false. For example, to disable the automatic placement of signs for the LSP diagnostic messages, you can add the following line to your .vimrc file: >