]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Pass additional client capabilities during initialization
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 1 Jan 2021 08:25:06 +0000 (00:25 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 1 Jan 2021 08:25:06 +0000 (00:25 -0800)
autoload/handlers.vim
autoload/lsp.vim
autoload/lspserver.vim

index 2b2a31e61b93a12013039ed65a16ebc362b044aa..b0d75ffe01f06610d4bd7a31c79444d3ad81678a 100644 (file)
@@ -84,9 +84,9 @@ def s:processSignaturehelpReply(lspserver: dict<any>, req: dict<any>, reply: dic
     endif
   endif
   var popupID = popup_atcursor(text, {})
-  prop_type_add('signature', {bufnr: popupID->winbufnr(), highlight: 'Title'})
+  prop_type_add('signature', {bufnr: winbufnr(popupID), highlight: 'Title'})
   if hllen > 0
-    prop_add(1, startcol + 1, {bufnr: popupID->winbufnr(), length: hllen, type: 'signature'})
+    prop_add(1, startcol + 1, {bufnr: winbufnr(popupID), length: hllen, type: 'signature'})
   endif
 enddef
 
@@ -150,10 +150,10 @@ def s:processCompletionReply(lspserver: dict<any>, req: dict<any>, reply: dict<a
       d.kind = LspCompleteItemKindChar(item.kind)
     endif
     if item->has_key('detail')
-      d.menu = item.detail
+      d.info = item.detail
     endif
     if item->has_key('documentation')
-      d.info = item.documentation
+      d.menu = item.documentation
     endif
     lspserver.completeItems->add(d)
   endfor
@@ -733,8 +733,14 @@ def s:processFoldingRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict
   endif
 
   # result: FoldingRange[]
+  var end_lnum: number
+  var last_lnum: number = line('$')
   for foldRange in reply.result
-    exe ':' .. (foldRange.startLine + 1) .. ',' .. (foldRange.endLine + 2) .. 'fold'
+    end_lnum = foldRange.endLine + 1
+    if end_lnum < foldRange.startLine + 2
+    end_lnum = foldRange.startLine + 2
+    endif
+    exe ':' .. (foldRange.startLine + 2) .. ',' .. end_lnum .. 'fold'
     :foldopen!
   endfor
 
index 7806aa07d3c8fcbb341576f8648cbade05a025e3..0309dd36222fccce60082864f9ca4b423516c122 100644 (file)
@@ -215,7 +215,8 @@ def lsp#addFile(bnr: number): void
   # add a listener to track changes to this buffer
   listener_add(function('lsp#bufchange_listener'), bnr)
   setbufvar(bnr, '&completefunc', 'lsp#completeFunc')
-  setbufvar(bnr, '&completeopt', 'menuone,preview,noinsert')
+  setbufvar(bnr, '&completeopt', 'menuone,popup,noinsert,noselect')
+  setbufvar(bnr, '&completepopup', 'border:off')
 
   # map characters that trigger signature help
   if lspserver.caps->has_key('signatureHelpProvider')
index 42faec8b11f6b1702d5c7089e4a87f525f8052cb..218aa7d047461c2e6b647d6d0fc6df9b59a8450a 100644 (file)
@@ -72,16 +72,31 @@ enddef
 def s:initServer(lspserver: dict<any>)
   var req = lspserver.createRequest('initialize')
 
+  # client capabilities (ClientCapabilities)
   var clientCaps: dict<any> = {
     workspace: {
       workspaceFolders: v:true,
       applyEdit: v:true,
     },
     textDocument: {
-      foldingRange: {lineFoldingOnly: v:true}
+      foldingRange: {lineFoldingOnly: v:true},
+      completion: {
+       snippetSupport: v:true,
+       completionItem: {
+         documentationFormat: ['plaintext', 'markdown'],
+       },
+       completionItemKind: {valueSet: range(1, 25)}
+      },
+      documentSymbol: {
+       hierarchicalDocumentSymbolSupport: v:true,
+       symbolKind: {valueSet: range(1, 25)}
+      },
+      hover: {
+        contentFormat: ['plaintext', 'markdown']
+      }
     },
     window: {},
-    general: {}
+    general: {},
   }
 
   # interface 'InitializeParams'
@@ -91,12 +106,14 @@ def s:initServer(lspserver: dict<any>)
        name: 'Vim',
        version: string(v:versionlong),
       }
-  initparams.rootPath = getcwd()
-  initparams.rootUri = LspFileToUri(getcwd())
+  var curdir: string = getcwd()
+  initparams.rootPath = curdir
+  initparams.rootUri = LspFileToUri(curdir)
   initparams.workspaceFolders = {
-       uri: LspFileToUri(getcwd()),
-       name: getcwd()
+       name: fnamemodify(curdir, ':t'),
+       uri: LspFileToUri(curdir)
       }
+  initparams.trace = 'off'
   initparams.capabilities = clientCaps
   req.params->extend(initparams)
 
@@ -332,6 +349,8 @@ def s:getCompletion(lspserver: dict<any>): void
   # interface CompletionParams
   #   interface TextDocumentPositionParams
   req.params->extend(s:getLspTextDocPosition())
+  #   interface CompletionContext
+  req.params->extend({context: {triggerKind: 1}})
 
   lspserver.sendMessage(req)
 enddef