nix-config/modules/home/vim/plugin/signtoggle.lua
Bruno BELANYI 5918a0b9e6 home: vim: signtoggle: use lua callbacks
Use `vim.opt` because this is a local option (i.e: similar to `set` it
defaults to setting it locally, `vim.opt_local` is not necessary).
2024-07-19 11:38:55 +00:00

27 lines
726 B
Lua

local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
-- Only show sign column for the currently focused buffer
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
pattern = "*",
group = signtoggle,
callback = function()
vim.opt.signcolumn = "yes"
end,
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
pattern = "*",
group = signtoggle,
callback = function()
vim.opt.signcolumn = "no"
end,
})
-- Never show the sign column in a terminal buffer
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = "*",
group = signtoggle,
callback = function()
vim.opt.signcolumn = "no"
end,
})