Skip to content

Commit d9c2978

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

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
@@ -685,15 +685,34 @@ require('lazy').setup({
685685
end,
686686
})
687687

688-
-- Change diagnostic symbols in the sign column (gutter)
689-
-- if vim.g.have_nerd_font then
690-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
691-
-- local diagnostic_signs = {}
692-
-- for type, icon in pairs(signs) do
693-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
694-
-- end
695-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
696-
-- end
688+
-- Diagnostic Config
689+
-- See :help vim.diagnostic.Opts
690+
vim.diagnostic.config {
691+
severity_sort = true,
692+
float = { border = 'rounded', source = 'if_many' },
693+
underline = { severity = vim.diagnostic.severity.ERROR },
694+
signs = vim.g.have_nerd_font and {
695+
text = {
696+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
697+
[vim.diagnostic.severity.WARN] = '󰀪 ',
698+
[vim.diagnostic.severity.INFO] = '󰋽 ',
699+
[vim.diagnostic.severity.HINT] = '󰌶 ',
700+
},
701+
} or {},
702+
virtual_text = {
703+
source = 'if_many',
704+
spacing = 2,
705+
format = function(diagnostic)
706+
local diagnostic_message = {
707+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
708+
[vim.diagnostic.severity.WARN] = diagnostic.message,
709+
[vim.diagnostic.severity.INFO] = diagnostic.message,
710+
[vim.diagnostic.severity.HINT] = diagnostic.message,
711+
}
712+
return diagnostic_message[diagnostic.severity]
713+
end,
714+
},
715+
}
697716

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

0 commit comments

Comments
 (0)