Skip to content

Commit e474c15

Browse files
gelocraftShrinivas Kamath
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent 92618b3 commit e474c15

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
@@ -609,15 +609,34 @@ require('lazy').setup({
609609
end,
610610
})
611611

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

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

0 commit comments

Comments
 (0)