feat(vim): setup document highlighting and diagnostics on hover
Now when the editor is idle it will use the lsp to highlight other references to the token under the cursor. It will also show all the diagnostics in a popup like the lsp hover that I manually use via <C-k>. This is helpful with long diagnostic messages that run off the edge of the terminal when.
This commit is contained in:
parent
6c5b2573ae
commit
ce7b395e90
1 changed files with 24 additions and 0 deletions
|
|
@ -83,3 +83,27 @@ vim.diagnostic.config({
|
||||||
border = border
|
border = border
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.cmd([[set updatetime=1000]])
|
||||||
|
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||||
|
callback = function ()
|
||||||
|
-- Highlight document symbles for every file type other erb files because
|
||||||
|
-- solargraph only supports textDocument/documentHighlight in rb files.
|
||||||
|
local file_type = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
|
if file_type ~= "eruby" then
|
||||||
|
vim.lsp.buf.document_highlight()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.diagnostic.open_float()
|
||||||
|
end,
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
desc = "Document Highlight",
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
callback = function ()
|
||||||
|
vim.lsp.buf.clear_references()
|
||||||
|
end,
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
desc = "Clear All the References",
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue