nix-config/modules/home/vim/plugin/signtoggle.lua
Bruno BELANYI 6f5ac4e55f
All checks were successful
ci/woodpecker/push/check Pipeline was successful
home: vim: signtoggle: only show signs if 'number'
If a buffer doesn't show a number column, I probably also don't want a
sign column to be toggled on/off in there.
2025-04-14 10:24:33 +00:00

21 lines
646 B
Lua

local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
-- Only show sign column for the currently focused buffer, if it has a number column
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
pattern = "*",
group = signtoggle,
callback = function()
if vim.opt.number:get() then
vim.opt.signcolumn = "yes"
end
end,
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
pattern = "*",
group = signtoggle,
callback = function()
if vim.opt.number:get() then
vim.opt.signcolumn = "no"
end
end,
})