refactor(nvim): improve diag signs setup
Some checks failed
Check Formatting of Files / Check-Formatting (push) Has been cancelled

This commit is contained in:
Price Hiller 2024-06-13 15:36:21 -05:00
parent e65eeea36a
commit 235a0ff229
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
5 changed files with 37 additions and 34 deletions

View File

@ -1,18 +1,7 @@
local M = {}
M.setup = function()
local function lspSymbol(name, icon)
local hl = "DiagnosticSign" .. name
vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl })
end
lspSymbol("Error", "󰅙")
lspSymbol("Warn", "")
lspSymbol("Info", "󰋼")
lspSymbol("Hint", "")
vim.diagnostic.config({
virtual_text = false,
virtual_lines = true,
severity_sort = true,
underline = true,
update_in_insert = false,
@ -23,24 +12,15 @@ M.setup = function()
[vim.diagnostic.severity.INFO] = "󰋼",
[vim.diagnostic.severity.HINT] = "",
},
numhl = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
linehl = {
[vim.diagnostic.severity.ERROR] = "CustomErrorBg",
},
},
float = {
focusable = true,
style = "minimal",
border = {
" ",
" ",
" ",
" ",
},
source = "always",
header = "Diagnostic",
border = "solid",
source = "if_many",
prefix = "",
},
})

View File

@ -11,6 +11,7 @@ return {
lsp_keymaps = false,
dap_debug_keymap = false,
lsp_codelens = false,
diagnostic = false,
icons = false,
run_in_floaterm = true,
trouble = true,

View File

@ -612,10 +612,10 @@ return {
{
condition = conditions.has_diagnostics,
static = {
error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text,
warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text,
info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text,
hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text,
error_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.ERROR] .. " ",
warn_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.WARN] .. " ",
info_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.INFO] .. " ",
hint_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.HINT] .. " ",
},
init = function(self)
self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })

View File

@ -44,12 +44,20 @@ return {
--
---@type { [1]: string, [2]: vim.api.keyset.highlight | fun(): vim.api.keyset.highlight | table<Highlight.Keys, fun(): string | integer> }[]
local extra_hls = {
-- For diagnostics
{ "CustomErrorBg", { bg = "#3d1b22" } },
-- Nvim notify
{ "NvimNotifyError", { fg = colors.samuraiRed } },
{ "NvimNotifyWarn", { fg = colors.roninYellow } },
{ "NvimNotifyInfo", { fg = colors.springGreen } },
{ "NvimNotifyDebug", { fg = colors.crystalBlue } },
{ "NvimNotifyTrace", { fg = colors.oniViolet } },
-- Built-ins
{ "StatusLineNC", { bg = nil } },
{ "menuSel", { bg = colors.sumiInk0, fg = "NONE" } },
{ "Pmenu", { fg = colors.fujiWhite, bg = colors.sumiInk2 } },
{ "WinBarNC", { bg = nil } },
{ "Visual", { bg = colors.sumiInk5 } },
{ "CursorLine", { bg = colors.sumiInk4 } },
@ -59,6 +67,18 @@ return {
{ "WinSeparator", { fg = colors.fujiGray } },
{ "StatusLine", { fg = colors.fujiWhite, bg = colors.sumiInk0 } },
{ "WinBar", { link = "StatusLine" } },
-- Gitsigns Colors
{ "GitSignsAdd", { fg = colors.autumnGreen } },
{ "GitSignsDelete", { fg = colors.autumnRed } },
{ "GitSignsChange", { fg = colors.autumnYellow } },
{ "GitSignsStagedAdd", { link = "GitSignsChangeAdd" } },
{ "GitSignsStagedDelete", { link = "GitSignsDelete" } },
{ "GitSignsStagedChangedelete", { link = "GitSignsDelete" } },
{ "GitSignsStagedChange", { link = "GitSignsChange" } },
{ "GitSignsUntracked", { link = "GitSignsChange" } },
-- Neogit
{ "NeogitCommandText", { fg = colors.oniViolet2 } },
{ "NeogitPopupSectionTitle", { fg = colors.crystalBlue } },
{ "NeogitPopupConfigEnabled", { fg = colors.springBlue, italic = true } },
@ -96,8 +116,8 @@ return {
{ "NeogitNotificationInfo", { fg = colors.springGreen, bold = true } },
{ "NeogitNotificationWarning", { fg = colors.roninYellow, bold = true } },
{ "NeogitNotificationError", { fg = colors.samuraiRed, bold = true } },
{ "menuSel", { bg = colors.sumiInk0, fg = "NONE" } },
{ "Pmenu", { fg = colors.fujiWhite, bg = colors.sumiInk2 } },
-- Cmp
{ "CmpGhostText", { fg = colors.boatYellow1, italic = true } },
{ "CmpItemAbbrDeprecated", { fg = colors.fujiGray, bg = "NONE" } },
{ "CmpItemAbbrMatch", { fg = colors.crystalBlue, bg = "NONE" } },
@ -145,6 +165,8 @@ return {
{ "CmpCustomSelectionCommit", { fg = colors.fujiWhite, bg = colors.peachRed } },
{ "CmpCustomSelectionSnippet", { fg = colors.fujiWhite, bg = colors.peachRed } },
{ "CmpCustomSelectionLuaLatexSymbol", { fg = colors.fujiWhite, bg = colors.surimiOrange } },
-- Telescope
{ "TelescopeNormal", { bg = colors.sumiInk2 } },
{ "TelescopeBorder", { bg = colors.sumiInk2, fg = colors.sumiInk1 } },
{ "TelescopePromptBorder", { bg = colors.sumiInk0, fg = colors.sumiInk0 } },
@ -154,6 +176,7 @@ return {
{ "TelescopePreviewNormal", { bg = colors.sumiInk4 } },
{ "TelescopePreviewBorder", { link = "TelescopePreviewNormal" } },
{ "TelescopeResultsTitle", { fg = "NONE", bg = "NONE" } },
{ "IlluminatedWordText", { bg = colors.waveBlue2 } },
{ "IlluminatedWordRead", { bg = colors.waveBlue2 } },
{ "IlluminatedWordWrite", { bg = colors.waveBlue2 } },

View File

@ -252,22 +252,21 @@ return {
{
"<leader>ls",
function()
vim.diagnostic.open_float(nil, { focus = true, scope = "cursor" })
vim.cmd.vsplit()
vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" })
end,
desc = "LSP: Diagnostic Open Float",
},
{
"[l",
function()
vim.diagnostic.jump({ count = -1 })
vim.diagnostic.jump({ count = -1, float = true })
end,
desc = "LSP: Diagnostic Previous",
},
{
"]l",
function()
vim.diagnostic.jump({ count = 1 })
vim.diagnostic.jump({ count = 1, float = true })
end,
desc = "LSP: Diagnostic Next",
},