From cb7f87aa3ff10e89fed75d18e7dfba334e4a36f2 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 21 Jan 2024 03:33:40 -0600 Subject: [PATCH] feat(nvim): extend CursorLine into the status column --- .../nvim/lua/plugins/configs/kanagawa.lua | 3 ++ .../nvim/lua/plugins/configs/statuscol.lua | 34 ++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/dots/.config/nvim/lua/plugins/configs/kanagawa.lua b/dots/.config/nvim/lua/plugins/configs/kanagawa.lua index 2bd57506..99658a41 100644 --- a/dots/.config/nvim/lua/plugins/configs/kanagawa.lua +++ b/dots/.config/nvim/lua/plugins/configs/kanagawa.lua @@ -83,6 +83,9 @@ return { ["@keyword.import"] = { link = "@include" }, ["@keyword.repeat"] = { link = "@repeat" }, + CursorLineNr = { fg = colors.roninYellow, bg = palette.theme.ui.bg_p1 }, + CursorLineFold = { fg = colors.crystalBlue, bg = palette.theme.ui.bg_p1 }, + CursorLineSign = { bg = palette.theme.ui.bg_p1 }, WinSeparator = { fg = colors.fujiGray }, StatusLine = { fg = colors.fujiWhite, bg = colors.sumiInk0 }, WinBar = { fg = colors.fujiWhite, bg = nil }, diff --git a/dots/.config/nvim/lua/plugins/configs/statuscol.lua b/dots/.config/nvim/lua/plugins/configs/statuscol.lua index 7b729836..350baa73 100644 --- a/dots/.config/nvim/lua/plugins/configs/statuscol.lua +++ b/dots/.config/nvim/lua/plugins/configs/statuscol.lua @@ -3,13 +3,37 @@ return { "luukvbaal/statuscol.nvim", opts = function() local builtin = require("statuscol.builtin") + local last_sign_def_len = 0 + + -- HACK: Ensure all signs get the correct CursorLineSign set to their "culhl" value + -- This, in effect, extends the CursorLine background highlight into the signcolumn + vim.uv.new_timer():start(50, 1000, vim.schedule_wrap(function() + -- Make all signs support "CusorLine.*" highlights + local signs_defined = vim.fn.sign_getdefined() + if #signs_defined == last_sign_def_len or #signs_defined == 0 then + return + end + last_sign_def_len = signs_defined + local bg = vim.api.nvim_get_hl(0, { name = "SignColumn", link = false }).bg + local cl_bg = vim.api.nvim_get_hl(0, { name = "CursorLineSign", link = false }).bg + for _, sign in ipairs(signs_defined) do + local name = sign.texthl + if name then + local hl = vim.api.nvim_get_hl(0, { name = name, link = false }) + vim.api.nvim_set_hl(0, name, { fg = hl.fg, bg = bg }) + name = name .. "Cul" + vim.api.nvim_set_hl(0, name, { fg = hl.fg, bg = cl_bg }) + vim.fn.sign_define(sign.name, { culhl = name }) + end + end + end)) + return { - foldfunc = "builtin", setopt = true, relculright = false, segments = { - { text = { "%s" }, click = "v:lua.ScSa" }, - { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, { text = { " ", builtin.foldfunc, " " }, click = "v:lua.ScFa" }, }, } @@ -23,6 +47,8 @@ return { current_line_blame_opts = { delay = 0, }, - }, + -- HACK: This allows the gitsigns to correctly use the culhl for their bg + _extmark_signs = false + } }, }