]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
add useBufferCompletion option
authorOleksiy Hryshchenko <greeschenko@gmail.com>
Fri, 21 Apr 2023 20:29:02 +0000 (23:29 +0300)
committerOleksiy Hryshchenko <greeschenko@gmail.com>
Fri, 21 Apr 2023 20:29:02 +0000 (23:29 +0300)
autoload/lsp/completion.vim
autoload/lsp/options.vim
doc/lsp.txt

index 77e24867f3644f9d5505d5fa0b22728624072cde..607d78d52e69fdcfc3155f3daa3330f05cd24357 100644 (file)
@@ -172,22 +172,24 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
     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<dict<any>> = []
   for item in items
index ef708ee09dcc3cc2a57fd9d7bf72263498a23ae6..8e29c79e2ae39a0832b7ea49cac7359f601d8242 100644 (file)
@@ -67,6 +67,8 @@ export var lspOptions: dict<any> = {
   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
index 5edad1cee1fd701a2989c049ba101fbf1d926250..ef60be1226c974b53e1fb20e442de7826826bb9a 100644 (file)
@@ -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: >