fix issue with diagnostics and gitsigns not rendering in the correct order

This commit is contained in:
gnat 2024-09-09 22:07:27 -07:00
parent a1a1b05f99
commit d5ccc1935d
3 changed files with 51 additions and 43 deletions

View File

@ -1,3 +1,5 @@
" this file is managed by my personal theme management script.
set background=dark
colorscheme oxocarbon
hi MyNormalMode guibg=#33b1ff guifg=#161616
@ -15,5 +17,11 @@ hi tabSepInactive2 guifg=#3c3836 guibg=#262626
hi tabSepSpecial guifg=#FF7EB6 guibg=#262626
hi tabSepSpecial2 guifg=#262626 guibg=#262626
hi tabSepSpecial3 guifg=#262626 guibg=#262626
highlight GitSignsAdd guibg=#161616 guifg=#42be65
highlight GitSignsChange guibg=#161616 guifg=#33b1ff
highlight GitSignsDelete guibg=#161616 guifg=#ee5396
highlight GitSignsTopDelete guibg=#161616 guifg=#ee5396
highlight GitSignsChangeDelete guibg=#161616 guifg=#ee5396
highlight GitSignsUntracked guibg=#161616 guifg=#be95ff
luafile ~/.config/nvim/lua/core/statusline.lua
luafile ~/.config/nvim/lua/core/tabline.lua

View File

@ -1,33 +1,31 @@
function capitalize_head_exclusive(str)
function capitalize_head(str)
str = string.lower(str)
str = string.gsub(str, "^%l", string.upper)
return str
end
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
local max_width = math.min(math.floor(vim.o.columns * 0.7), 100)
local max_height = math.min(math.floor(vim.o.lines * 0.3), 30)
local signs = {
[vim.diagnostic.severity.ERROR] = "E",
[vim.diagnostic.severity.WARN] = "W",
[vim.diagnostic.severity.HINT] = "H",
[vim.diagnostic.severity.INFO] = "I"
}
vim.diagnostic.config({
underline = true,
update_in_insert = true,
severity_sort = true,
virtual_text = false and {
spacing = 1,
prefix = '', -- TODO: in nvim-0.10.0 this can be a function, so format won't be necessary
format = function(d)
local level = vim.diagnostic.severity[d.severity]
return string.format('%s %s', signs[capitalize_head_exclusive(level)], d.message)
end,
virtual_text = false,
signs = {
severity = { min = vim.diagnostic.severity.HINT },
text = signs,
priority = 4,
},
float = {
max_width = max_width,
max_height = max_height,
max_width = math.min(math.floor(vim.o.columns * 0.7), 100),
max_height = math.min(math.floor(vim.o.lines * 0.3), 30),
border = border_style,
title = { { '', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } },
focusable = false,
@ -35,11 +33,14 @@ vim.diagnostic.config({
source = 'if_many',
prefix = function(diag)
local level = vim.diagnostic.severity[diag.severity]
local prefix = string.format('%s ', signs[capitalize_head_exclusive(level)])
local prefix = string.format('%s ', signs[diag.severity])
return prefix, 'Diagnostic' .. level:gsub('^%l', string.upper)
end,
},
})
vim.cmd [[ autocmd! CursorHold * lua vim.diagnostic.open_float()]]
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

View File

@ -1,49 +1,48 @@
return {
return {
'lewis6991/gitsigns.nvim',
event = { 'BufEnter' },
config = function()
require('gitsigns').setup {
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '' },
topdelete = { text = '' },
changedelete = { text = '' },
untracked = { text = '' },
add = { text = '' },
change = { text = '' },
delete = { text = '' },
topdelete = { text = '' },
changedelete = { text = '' },
untracked = { text = '' },
},
signs_staged = {
add = { text = '' },
change = { text = '' },
delete = { text = '' },
topdelete = { text = '' },
changedelete = { text = '' },
untracked = { text = '' },
add = { text = '' },
change = { text = '' },
delete = { text = '' },
topdelete = { text = '' },
changedelete = { text = '' },
untracked = { text = '' },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
signcolumn = true,
numhl = false,
linehl = false,
word_diff = false,
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame = false,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
virt_text_pos = 'eol',
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
sign_priority = 10,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
status_formatter = nil,
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',