Skip to content

Commit 2cacba5

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

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
@@ -735,15 +735,34 @@ require('lazy').setup({
735735
end,
736736
})
737737

738-
-- Change diagnostic symbols in the sign column (gutter)
739-
-- if vim.g.have_nerd_font then
740-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
741-
-- local diagnostic_signs = {}
742-
-- for type, icon in pairs(signs) do
743-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
744-
-- end
745-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
746-
-- end
738+
-- Diagnostic Config
739+
-- See :help vim.diagnostic.Opts
740+
vim.diagnostic.config {
741+
severity_sort = true,
742+
float = { border = 'rounded', source = 'if_many' },
743+
underline = { severity = vim.diagnostic.severity.ERROR },
744+
signs = vim.g.have_nerd_font and {
745+
text = {
746+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
747+
[vim.diagnostic.severity.WARN] = '󰀪 ',
748+
[vim.diagnostic.severity.INFO] = '󰋽 ',
749+
[vim.diagnostic.severity.HINT] = '󰌶 ',
750+
},
751+
} or {},
752+
virtual_text = {
753+
source = 'if_many',
754+
spacing = 2,
755+
format = function(diagnostic)
756+
local diagnostic_message = {
757+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
758+
[vim.diagnostic.severity.WARN] = diagnostic.message,
759+
[vim.diagnostic.severity.INFO] = diagnostic.message,
760+
[vim.diagnostic.severity.HINT] = diagnostic.message,
761+
}
762+
return diagnostic_message[diagnostic.severity]
763+
end,
764+
},
765+
}
747766

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

0 commit comments

Comments
 (0)