home: vim: signtoggle: only show signs if 'number'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
All checks were successful
ci/woodpecker/push/check Pipeline was successful
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.
This commit is contained in:
parent
67936af4c7
commit
6f5ac4e55f
1 changed files with 7 additions and 3 deletions
|
|
@ -1,17 +1,21 @@
|
||||||
local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
|
local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
|
||||||
|
|
||||||
-- Only show sign column for the currently focused buffer
|
-- Only show sign column for the currently focused buffer, if it has a number column
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
|
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = signtoggle,
|
group = signtoggle,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt.signcolumn = "yes"
|
if vim.opt.number:get() then
|
||||||
|
vim.opt.signcolumn = "yes"
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
|
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = signtoggle,
|
group = signtoggle,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt.signcolumn = "no"
|
if vim.opt.number:get() then
|
||||||
|
vim.opt.signcolumn = "no"
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue