autoload/lsp/lsp.vim | 6 +++--- autoload/lsp/lspserver.vim | 14 +++++++++----- plugin/lsp.vim | 2 +- diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index f62403ebe5bf471f4e44e5342bab8db6b5b78d25..f909ded67f51a1ec5f9913ed4269a1fd564b25b4 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -395,7 +395,7 @@ lspserver.isDocumentHighlightProvider acmds->add({bufnr: bnr, event: 'CursorMoved', group: 'LSPBufferAutocmds', - cmd: 'call LspDocHighlightClear() | call LspDocHighlight()'}) + cmd: 'call LspDocHighlightClear() | call LspDocHighlight("silent")'}) endif # Show diagnostics on the status line @@ -757,13 +757,13 @@ lspserver.showReferences(peek) enddef # highlight all the places where a symbol is referenced -def g:LspDocHighlight() +def g:LspDocHighlight(cmdmods: string = '') var lspserver: dict = buf.CurbufGetServerChecked('documentHighlight') if lspserver->empty() return endif - lspserver.docHighlight() + lspserver.docHighlight(cmdmods) enddef # clear the symbol reference highlight diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 911383ea83f23d7ac78712ea857966d2d6b8c455..6f4f559fba5268d6bb409d170c4497669a90e157 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -868,9 +868,12 @@ enddef # process the 'textDocument/documentHighlight' reply from the LSP server # Result: DocumentHighlight[] | null -def DocHighlightReply(bnr: number, lspserver: dict, docHighlightReply: any): void +def DocHighlightReply(lspserver: dict, docHighlightReply: any, + bnr: number, cmdmods: string): void if docHighlightReply->empty() - util.WarnMsg($'No highlight for the current position') + if cmdmods !~ 'silent' + util.WarnMsg($'No highlight for the current position') + endif return endif @@ -898,7 +901,7 @@ enddef # Request: "textDocument/documentHighlight" # Param: DocumentHighlightParams -def DocHighlight(lspserver: dict): void +def DocHighlight(lspserver: dict, cmdmods: string): void # Check whether LSP server supports getting highlight information if !lspserver.isDocumentHighlightProvider util.ErrMsg('Error: LSP server does not support document highlight') @@ -908,8 +911,9 @@ # interface DocumentHighlightParams # interface TextDocumentPositionParams var params = GetLspTextDocPosition(false) - lspserver.rpc_a('textDocument/documentHighlight', params, - function('DocHighlightReply', [bufnr()])) + lspserver.rpc_a('textDocument/documentHighlight', params, (_, reply) => { + DocHighlightReply(lspserver, reply, bufnr(), cmdmods) + }) enddef # Request: "textDocument/documentSymbol" diff --git a/plugin/lsp.vim b/plugin/lsp.vim index c0f1eb575b8bace8a514f8b59f2f6cf31bf5eb42..4abb8b9bade1050c910df7e447ee2ffc348493fb 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -73,7 +73,7 @@ command! -nargs=0 -bar LspGotoDeclaration lsp.GotoDeclaration(v:false, ) command! -nargs=0 -bar LspGotoDefinition lsp.GotoDefinition(v:false, ) command! -nargs=0 -bar LspGotoImpl lsp.GotoImplementation(v:false, ) command! -nargs=0 -bar LspGotoTypeDef lsp.GotoTypedef(v:false, ) -command! -nargs=0 -bar LspHighlight call LspDocHighlight() +command! -nargs=0 -bar LspHighlight call LspDocHighlight() command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear() command! -nargs=0 -bar LspHover lsp.Hover() command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()