Skip to content

Commit e442673

Browse files
gelocraftpetalas
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <[email protected]>
1 parent d130ce1 commit e442673

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
@@ -621,15 +621,34 @@ require('lazy').setup({
621621
end,
622622
})
623623

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

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

0 commit comments

Comments
 (0)