Skip to content

Commit 4f819c9

Browse files
gelocraftNickalas Cason
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent b122f0d commit 4f819c9

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

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

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

0 commit comments

Comments
 (0)