Skip to content

Commit 14167b7

Browse files
gelocraftzenvignesh
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent eb8532b commit 14167b7

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

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

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

0 commit comments

Comments
 (0)