feat/pack (#1)
Reviewed-on: #1 Co-authored-by: Tomas Mirchev <contact@tomastm.com> Co-committed-by: Tomas Mirchev <contact@tomastm.com>
This commit was merged in pull request #1.
This commit is contained in:
42
lua/modules/diagnostics.lua
Normal file
42
lua/modules/diagnostics.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
-- Diagnostics
|
||||
local special_sources = {
|
||||
lua_ls = 'lua',
|
||||
}
|
||||
vim.diagnostic.config({
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
virtual_text = {
|
||||
format = function(diagnostic)
|
||||
local src = diagnostic.source and (special_sources[diagnostic.source] or diagnostic.source)
|
||||
if src then
|
||||
return string.format('%s: %s', src, diagnostic.message)
|
||||
end
|
||||
return diagnostic.message
|
||||
end,
|
||||
},
|
||||
float = {
|
||||
border = 'rounded',
|
||||
header = '',
|
||||
format = function(diagnostic)
|
||||
local src = diagnostic.source and (special_sources[diagnostic.source] or diagnostic.source)
|
||||
if src then
|
||||
return string.format('%s: %s', src, diagnostic.message)
|
||||
end
|
||||
return diagnostic.message
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- Override the virtual text diagnostic handler so that the most severe diagnostic is shown first.
|
||||
local show_handler = vim.diagnostic.handlers.virtual_text.show
|
||||
assert(show_handler)
|
||||
local hide_handler = vim.diagnostic.handlers.virtual_text.hide
|
||||
vim.diagnostic.handlers.virtual_text = {
|
||||
show = function(ns, bufnr, diagnostics, opts)
|
||||
table.sort(diagnostics, function(diag1, diag2)
|
||||
return diag1.severity > diag2.severity
|
||||
end)
|
||||
return show_handler(ns, bufnr, diagnostics, opts)
|
||||
end,
|
||||
hide = hide_handler,
|
||||
}
|
||||
Reference in New Issue
Block a user