lspserver.sendMessage(req)
enddef
+# Display the LSP server capabilities (received during the initialization
+# stage).
+def s:showCapabilities(lspserver: dict<any>)
+ echo "Capabilities of '" .. lspserver.path .. "' LSP server:"
+ for k in lspserver.caps->keys()->sort()
+ echo k .. ": " .. lspserver.caps[k]->string()
+ endfor
+enddef
+
export def NewLspServer(path: string, args: list<string>): dict<any>
var lspserver: dict<any> = {
path: path,
removeWorkspaceFolder: function('s:removeWorkspaceFolder', [lspserver]),
selectionRange: function('s:selectionRange', [lspserver]),
foldRange: function('s:foldRange', [lspserver]),
- executeCommand: function('s:executeCommand', [lspserver])
+ executeCommand: function('s:executeCommand', [lspserver]),
+ showCapabilities: function('s:showCapabilities', [lspserver])
})
return lspserver
Remove a folder from the workspace
:LspWorkspaceListFolders
Show the list of folders in the workspace
+:LspShowServerCapabilities
+ Display the list of capabilities of a LSP server.
==============================================================================
4. Configuration *lsp-configuration*
:LspWorkspaceListFolders
Show the list of folders in the workspace.
+ *:LspShowServerCapabilities*
+:LspShowServerCapabilities
+ Display the list of capabilities of a LSP server.
+ The server capabilities are described in the LSP
+ protocol specification under the "ServerCapabilities"
+ interface.
+
==============================================================================
6. Insert mode completion
}
END
assert_equal(expected, getline(1, '$'))
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspFormat'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspFormat')->split("\n"))
:%bw!
enddef
WaitForAssert(() => assert_equal(1, getloclist(0)->len()))
qfl = getloclist(0)
assert_equal([1, 5], [qfl[0].lnum, qfl[0].col])
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspShowReferences'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspShowReferences')->split("\n"))
:%bw!
enddef
:LspCodeAction
sleep 500m
WaitForAssert(() => assert_equal("\tcount = 20;", getline(4)))
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspCodeAction'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspCodeAction')->split("\n"))
:%bw!
enddef
}
END
WaitForAssert(() => assert_equal(expected, getline(1, '$')))
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspRename'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspRename')->split("\n"))
+
:%bw!
enddef
normal! y
assert_equal('v', visualmode())
assert_equal([4, 5, 6, 5], [line("'<"), col("'<"), line("'>"), col("'>")])
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspSelectionRange'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspSelectionRange')->split("\n"))
+
:%bw!
enddef
m = execute('messages')->split("\n")
assert_equal('Error: implementation is not found', m[1])
endif
+ bw!
+
+ # empty file
+ assert_equal('', execute('LspGotoDefinition'))
+ assert_equal('', execute('LspGotoDeclaration'))
+ assert_equal('', execute('LspGotoImpl'))
+
+ # file without an LSP server
+ edit a.b
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspGotoDefinition')->split("\n"))
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspGotoDeclaration')->split("\n"))
+ assert_equal(['Error: LSP server for "a.b" is not found'],
+ execute('LspGotoImpl')->split("\n"))
+
:%bw!
enddef