2024-09-09 22:07:27 -07:00
|
|
|
function capitalize_head(str)
|
2024-07-30 10:06:43 -07:00
|
|
|
str = string.lower(str)
|
|
|
|
str = string.gsub(str, "^%l", string.upper)
|
|
|
|
return str
|
|
|
|
end
|
|
|
|
|
2024-09-09 22:07:27 -07:00
|
|
|
local signs = {
|
|
|
|
[vim.diagnostic.severity.ERROR] = "E",
|
|
|
|
[vim.diagnostic.severity.WARN] = "W",
|
|
|
|
[vim.diagnostic.severity.HINT] = "H",
|
|
|
|
[vim.diagnostic.severity.INFO] = "I"
|
|
|
|
}
|
2024-07-30 10:06:43 -07:00
|
|
|
|
|
|
|
vim.diagnostic.config({
|
|
|
|
underline = true,
|
|
|
|
update_in_insert = true,
|
|
|
|
severity_sort = true,
|
2024-09-09 22:07:27 -07:00
|
|
|
virtual_text = false,
|
|
|
|
|
|
|
|
signs = {
|
|
|
|
severity = { min = vim.diagnostic.severity.HINT },
|
|
|
|
text = signs,
|
|
|
|
priority = 4,
|
2024-07-30 10:06:43 -07:00
|
|
|
},
|
2024-09-09 22:07:27 -07:00
|
|
|
|
2024-07-30 10:06:43 -07:00
|
|
|
float = {
|
2024-09-09 22:07:27 -07:00
|
|
|
max_width = math.min(math.floor(vim.o.columns * 0.7), 100),
|
|
|
|
max_height = math.min(math.floor(vim.o.lines * 0.3), 30),
|
2024-07-30 10:06:43 -07:00
|
|
|
border = border_style,
|
|
|
|
title = { { ' ', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } },
|
|
|
|
focusable = false,
|
|
|
|
scope = 'line',
|
|
|
|
source = 'if_many',
|
|
|
|
prefix = function(diag)
|
|
|
|
local level = vim.diagnostic.severity[diag.severity]
|
2024-09-09 22:07:27 -07:00
|
|
|
local prefix = string.format('%s ', signs[diag.severity])
|
2024-07-30 10:06:43 -07:00
|
|
|
return prefix, 'Diagnostic' .. level:gsub('^%l', string.upper)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-09-09 22:07:27 -07:00
|
|
|
for severity, icon in pairs(signs) do
|
|
|
|
local hl = "DiagnosticSign" .. capitalize_head(vim.diagnostic.severity[severity])
|
|
|
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
|
|
|
end
|
2024-07-30 10:06:43 -07:00
|
|
|
|