Adjusted diagnostic config
This commit is contained in:
parent
1ff53112ae
commit
66d933cbb3
|
@ -64,19 +64,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
vim.keymap.set("n", "]d", function()
|
||||
vim.diagnostic.jump({ count = 1 })
|
||||
end, { desc = "Go to next diagnostic message" })
|
||||
-- vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
|
||||
vim.keymap.set("n", "<leader>e", function()
|
||||
if vim.diagnostic.config().virtual_lines then
|
||||
vim.diagnostic.config({ virtual_lines = false })
|
||||
else
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = {
|
||||
current_line = true,
|
||||
format = vim.diagnostic.config().virtual_text.format,
|
||||
},
|
||||
})
|
||||
end
|
||||
end, { desc = "Show virtual diagnostic line" })
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
|
||||
|
||||
-- Helpers
|
||||
vim.keymap.set("n", "<leader>rn", function()
|
||||
|
@ -132,10 +120,3 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
callback = function()
|
||||
vim.diagnostic.config({ virtual_lines = false })
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -82,10 +82,19 @@ vim.diagnostic.config({
|
|||
[vim.diagnostic.severity.INFO] = diagnostic.info,
|
||||
},
|
||||
},
|
||||
virtual_text = {
|
||||
virt_text_pos = "eol_right_align",
|
||||
format = function(d)
|
||||
return ("%s [%s]"):format(d.message, d.source)
|
||||
float = {
|
||||
severity_sort = false,
|
||||
header = "",
|
||||
suffix = function(d)
|
||||
local code = d.code and string.format(" (%s)", d.code) or ""
|
||||
|
||||
return string.format("%s [%s]", code, d.source), "NormalFloat"
|
||||
end,
|
||||
},
|
||||
virtual_text = {
|
||||
prefix = function(d)
|
||||
return vim.diagnostic.config().signs.text[d.severity]
|
||||
end,
|
||||
virt_text_pos = "eol_right_align",
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user