Skip to content

Commit 34b1d8c

Browse files
gelocraftarkottke
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent 876653f commit 34b1d8c

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

init.lua

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,34 @@ require('lazy').setup({
607607
end,
608608
})
609609

610-
-- Change diagnostic symbols in the sign column (gutter)
611-
-- if vim.g.have_nerd_font then
612-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
613-
-- local diagnostic_signs = {}
614-
-- for type, icon in pairs(signs) do
615-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
616-
-- end
617-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
618-
-- end
610+
-- Diagnostic Config
611+
-- See :help vim.diagnostic.Opts
612+
vim.diagnostic.config {
613+
severity_sort = true,
614+
float = { border = 'rounded', source = 'if_many' },
615+
underline = { severity = vim.diagnostic.severity.ERROR },
616+
signs = vim.g.have_nerd_font and {
617+
text = {
618+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
619+
[vim.diagnostic.severity.WARN] = '󰀪 ',
620+
[vim.diagnostic.severity.INFO] = '󰋽 ',
621+
[vim.diagnostic.severity.HINT] = '󰌶 ',
622+
},
623+
} or {},
624+
virtual_text = {
625+
source = 'if_many',
626+
spacing = 2,
627+
format = function(diagnostic)
628+
local diagnostic_message = {
629+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
630+
[vim.diagnostic.severity.WARN] = diagnostic.message,
631+
[vim.diagnostic.severity.INFO] = diagnostic.message,
632+
[vim.diagnostic.severity.HINT] = diagnostic.message,
633+
}
634+
return diagnostic_message[diagnostic.severity]
635+
end,
636+
},
637+
}
619638

620639
-- LSP servers and clients are able to communicate to each other what features they support.
621640
-- By default, Neovim doesn't support everything that is in the LSP specification.

0 commit comments

Comments
 (0)