From: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com> Date: Sun, 21 May 2023 19:35:28 +0000 (-0700) Subject: Merge branch 'main' into process-diags X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4c422bcb0e59bff656d6cdd44cd015fa97d7878e;p=vim-lsp.git Merge branch 'main' into process-diags --- 4c422bcb0e59bff656d6cdd44cd015fa97d7878e diff --cc autoload/lsp/lsp.vim index 4b13403,5e309df..bb204e3 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@@ -612,16 -612,11 +612,20 @@@ export def AddServer(serverList: listhas_key('processDiagHandler') + if server.processDiagHandler->type() != v:t_func + util.ErrMsg($'Setting of processDiagHandler {server.processDiagHandler} is not a Funcref nor lambda') + return + endif - + ProcessDiagHandler = server.processDiagHandler + endif + + var customRequestHandlers: dict = {} + if server->has_key('customRequestHandlers') + customRequestHandlers = server.customRequestHandlers + endif + var features: dict = {} if server->has_key('features') features = server.features @@@ -671,7 -666,7 +675,8 @@@ server.runIfSearch, server.runUnlessSearch, customNotificationHandlers, - ProcessDiagHandler, + customRequestHandlers, ++ ProcessDiagHandler, features, server.debug) var ftypes = server.filetype diff --cc autoload/lsp/lspserver.vim index ccd3c4d,031106e..8988cad --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@@ -1505,7 -1505,7 +1505,8 @@@ export def NewLspServer(name_arg: strin runIfSearchFiles: list, runUnlessSearchFiles: list, customNotificationHandlers: dict, - ProcessDiagHandler: func, + customRequestHandlers: dict, ++ ProcessDiagHandler: func, features: dict, debug_arg: bool): dict var lspserver: dict = { id: GetUniqueServerId(), @@@ -1515,7 -1515,7 +1516,8 @@@ syncInit: isSync, initializationOptions: initializationOptions, customNotificationHandlers: customNotificationHandlers, + customRequestHandlers: customRequestHandlers, + processDiagHandler: ProcessDiagHandler, features: features, running: false, ready: false, diff --cc doc/lsp.txt index 0a621b4,875685f..cabc041 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@@ -318,46 -327,8 +327,46 @@@ Additionally the following configuratio |lsp-features| for more information. *lsp-cfg-omnicompl* omnicompl (Optional) a boolean value that enables (true) -- or disables (false) omni-completion for this file - types. By default this is set to "true". ++ or disables (false) omni-completion for these file + types. By default this is set to "v:true". + *lsp-cfg-processDiagHandler* + processDiagHandler + (Optional) A |Funcref| or |lambda| that takes a list of + language server diagnostics and returns a new list of + filtered, or otherwise changed diagnostics. Can be used + to remove unwanted diagnostics, prefix the diagnostics + text, etc. The following example will remove all but + errors and warnings: > + + vim9script + g:LspAddServer([{ + filetype: ['javascript', 'typescript'], + path: '/usr/local/bin/typescript-language-server', + args: ['--stdio'], + processDiagHandler: (diags: list>) => { + # Only include errors and warnings + return diags->filter((diag, ix) => { + return diag.severity <= 2 + }) + }, + }]) +< + And this example will prefix the diagnostic message with + the string "TypeScript: ": > + + vim9script + g:LspAddServer([{ + filetype: ['javascript', 'typescript'], + path: '/usr/local/bin/typescript-language-server', + args: ['--stdio'], + processDiagHandler: (diags: list>) => { + return diags->map((diag, ix) => { + diag.message = $'TypeScript: {diag.message}' + return diag + }) + }, + }]) +< *lsp-cfg-syncInit* syncInit (Optional) for language servers (e.g. rust analyzer, gopls, etc.) that take time to initialize and reply to