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
enddef
# highlight all the places where a symbol is referenced
-def g:LspDocHighlight()
+def g:LspDocHighlight(cmdmods: string = '')
var lspserver: dict<any> = buf.CurbufGetServerChecked('documentHighlight')
if lspserver->empty()
return
endif
- lspserver.docHighlight()
+ lspserver.docHighlight(cmdmods)
enddef
# clear the symbol reference highlight
# process the 'textDocument/documentHighlight' reply from the LSP server
# Result: DocumentHighlight[] | null
-def DocHighlightReply(bnr: number, lspserver: dict<any>, docHighlightReply: any): void
+def DocHighlightReply(lspserver: dict<any>, 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
# Request: "textDocument/documentHighlight"
# Param: DocumentHighlightParams
-def DocHighlight(lspserver: dict<any>): void
+def DocHighlight(lspserver: dict<any>, cmdmods: string): void
# Check whether LSP server supports getting highlight information
if !lspserver.isDocumentHighlightProvider
util.ErrMsg('Error: LSP server does not support document highlight')
# 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"
command! -nargs=0 -bar LspGotoDefinition lsp.GotoDefinition(v:false, <q-mods>)
command! -nargs=0 -bar LspGotoImpl lsp.GotoImplementation(v:false, <q-mods>)
command! -nargs=0 -bar LspGotoTypeDef lsp.GotoTypedef(v:false, <q-mods>)
-command! -nargs=0 -bar LspHighlight call LspDocHighlight()
+command! -nargs=0 -bar LspHighlight call LspDocHighlight(<q-mods>)
command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear()
command! -nargs=0 -bar LspHover lsp.Hover(<q-mods>)
command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()