# process the workspace/configuration LSP server request
# Request: "workspace/configuration"
-# Param: none
+# Param: ConfigurationParams
def ProcessWorkspaceConfiguration(lspserver: dict<any>, request: dict<any>)
- lspserver.sendResponse(request, {}, {})
+ var items = request.params.items
+ var response = items->map((_, item) => lspserver.workspaceConfigGet(item))
+ lspserver.sendResponse(request, response, {})
enddef
# process the window/workDoneProgress/create LSP server request
# send a "initialized" notification to server
lspserver.sendInitializedNotif()
+ # send any workspace configuration (optional)
+ if !lspserver.workspaceConfig->empty()
+ lspserver.sendWorkspaceConfig()
+ endif
lspserver.ready = true
if exists($'#User#LspServerReady{lspserver.name}')
exe $'doautocmd <nomodeline> User LspServerReady{lspserver.name}'
endwhile
enddef
+# Retrieve the Workspace configuration asked by the server.
+# Request: workspace/configuration
+def WorkspaceConfigGet(lspserver: dict<any>, configItem: dict<any>): dict<any>
+ if lspserver.workspaceConfig->empty()
+ return {}
+ endif
+ if !configItem->has_key('section') || configItem.section->empty()
+ return lspserver.workspaceConfig
+ endif
+ var config: dict<any> = lspserver.workspaceConfig
+ for part in configItem.section->split('\.')
+ if !config->has_key(part)
+ return {}
+ endif
+ config = config[part]
+ endfor
+ return config
+enddef
+
+# Send a "workspace/didChangeConfiguration" notification to the language
+# server.
+def SendWorkspaceConfig(lspserver: dict<any>)
+ # Params: DidChangeConfigurationParams
+ var params = {settings: lspserver.workspaceConfig}
+ lspserver.sendNotification('workspace/didChangeConfiguration', params)
+enddef
+
# Send a file/document opened notification to the language server.
def TextdocDidOpen(lspserver: dict<any>, bnr: number, ftype: string): void
# Notification: 'textDocument/didOpen'
export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
isSync: bool, initializationOptions: any,
+ workspaceConfig: dict<any>,
customNotificationHandlers: dict<func>,
debug_arg: bool): dict<any>
var lspserver: dict<any> = {
peekSymbolFilePopup: -1,
callHierarchyType: '',
selection: {},
+ workspaceConfig: workspaceConfig,
debug: debug_arg
}
lspserver.logfile = $'lsp-{lspserver.name}.log'
textdocDidClose: function(TextdocDidClose, [lspserver]),
textdocDidChange: function(TextdocDidChange, [lspserver]),
sendInitializedNotif: function(SendInitializedNotif, [lspserver]),
+ sendWorkspaceConfig: function(SendWorkspaceConfig, [lspserver]),
getCompletion: function(GetCompletion, [lspserver]),
resolveCompletion: function(ResolveCompletion, [lspserver]),
gotoDefinition: function(GotoDefinition, [lspserver]),
selectionShrink: function(SelectionShrink, [lspserver]),
foldRange: function(FoldRange, [lspserver]),
executeCommand: function(ExecuteCommand, [lspserver]),
+ workspaceConfigGet: function(WorkspaceConfigGet, [lspserver]),
showCapabilities: function(ShowCapabilities, [lspserver])
})
or useful for initialization. Those can be provided in
this dictionary and if present will be transmitted to
the lsp server.
- *lsp-cfg-debug*
- debug (Optional) log the messages printed by this language
- server in stdout and stderr to a file. Useful for
- debugging a language server. By default the
- messages are not logged. See |lsp-debug| for more
- information.
+ *lsp-cfg-workspaceConfig*
+ workspaceConfig (Optional) a json encodable value that will be sent to
+ the language server after initialization as the
+ "settings" in a "workspace/didChangeConfiguration"
+ notification. Refer to the language server
+ documentation for the values that will be accepted in
+ this notification. This configuration is also used to
+ respond to the "workspace/configuration" request
+ message from the language server.
Aditionally the following configurations can be made:
call is used to initialize the language server,
otherwise the server is initialized asynchronously.
By default this is set to "v:false".
+ *lsp-cfg-debug*
+ debug (Optional) log the messages printed by this language
+ server in stdout and stderr to a file. Useful for
+ debugging a language server. By default the
+ messages are not logged. See |lsp-debug| for more
+ information.
The language servers are added using the LspAddServer() function. This function
accepts a list of language servers with the above information.