From 6deb3e7efcece6443d71f801c6a8b146d628a913 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Tue, 4 Jul 2023 16:03:42 -0700 Subject: [PATCH] Ignore unsupported pyright language server notifications. Fixes #355 --- autoload/lsp/handlers.vim | 24 ++++++++++++++---------- autoload/lsp/lsp.vim | 4 ++-- autoload/lsp/util.vim | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/autoload/lsp/handlers.vim b/autoload/lsp/handlers.vim index d0dbfff..45acb70 100644 --- a/autoload/lsp/handlers.vim +++ b/autoload/lsp/handlers.vim @@ -70,16 +70,16 @@ enddef # process unsupported notification messages def ProcessUnsupportedNotif(lspserver: dict, reply: dict) - util.ErrMsg($'Unsupported notification message received from the LSP server ({lspserver.path}), message = {reply->string()}') + util.WarnMsg($'Unsupported notification message received from the LSP server ({lspserver.name}), message = {reply->string()}') enddef -# per-filetype private map inside to record if ntf once or not -var ftypeNtfOnceMap: dict = {} -# process unsupported notification messages but only notify once +# Dict to process telemetry notification messages only once per filetype +var telemetryProcessed: dict = {} +# process unsupported notification messages only once def ProcessUnsupportedNotifOnce(lspserver: dict, reply: dict) - if !ftypeNtfOnceMap->get(&ft, v:false) - ProcessUnsupportedNotif(lspserver, reply) - ftypeNtfOnceMap->extend({[&ft]: v:true}) + if !telemetryProcessed->get(&ft, false) + ProcessUnsupportedNotif(lspserver, reply) + telemetryProcessed->extend({[&ft]: true}) endif enddef @@ -112,7 +112,11 @@ export def ProcessNotif(lspserver: dict, reply: dict): void '$/typescriptVersion', # Dart language server sends the '$/analyzerStatus' notification which # is not in the LSP specification. - '$/analyzerStatus' + '$/analyzerStatus', + # pyright language server notifications + 'pyright/beginProgress', + 'pyright/reportProgress', + 'pyright/endProgress' ] if lsp_notif_handlers->has_key(reply.method) @@ -120,7 +124,7 @@ export def ProcessNotif(lspserver: dict, reply: dict): void elseif lspserver.customNotificationHandlers->has_key(reply.method) lspserver.customNotificationHandlers[reply.method](lspserver, reply) elseif lsp_ignored_notif_handlers->index(reply.method) == -1 - util.ErrMsg($'Unsupported notification received from LSP server {reply->string()}') + ProcessUnsupportedNotif(lspserver, reply) endif enddef @@ -220,7 +224,7 @@ export def ProcessRequest(lspserver: dict, request: dict) elseif lspserver.customRequestHandlers->has_key(request.method) lspserver.customRequestHandlers[request.method](lspserver, request) elseif lspIgnoredRequestHandlers->index(request.method) == -1 - util.ErrMsg($'Unsupported request message received from the LSP server ({lspserver.path}), message = {request->string()}') + util.ErrMsg($'Unsupported request message received from the LSP server ({lspserver.name}), message = {request->string()}') endif enddef diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index a949407..adc8e7c 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -595,7 +595,7 @@ export def AddServer(serverList: list>) continue endif # Enable omni-completion by default - server.omnicompl = get(server, 'omnicompl', v:true) + server.omnicompl = server->get('omnicompl', true) if !server.path->executable() if !opt.lspOptions.ignoreMissingServer @@ -654,7 +654,7 @@ export def AddServer(serverList: list>) endif if !server->has_key('syncInit') - server.syncInit = v:false + server.syncInit = false endif if !server->has_key('name') || server.name->type() != v:t_string diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 34fc5a6..eb0a64f 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -210,7 +210,7 @@ export def GetCharIdxWithoutCompChar(bnr: number, pos: dict): number # Byte index points to the byte after the last byte. return ltext->strcharlen() else - return ltext->charidx(byteIdx, v:false) + return ltext->charidx(byteIdx, false) endif endif @@ -235,7 +235,7 @@ export def GetCharIdxWithCompChar(ltext: string, charIdx: number): number if byteIdx == ltext->strlen() return ltext->strchars() else - return ltext->charidx(byteIdx, v:true) + return ltext->charidx(byteIdx, true) endif endif -- 2.44.0