Compare commits

..

3 commits

Author SHA1 Message Date
Bruno BELANYI b1e484474f home: vim: signtoggle: use lua callbacks
All checks were successful
ci/woodpecker/push/check Pipeline was successful
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-18 20:24:28 +01:00
Bruno BELANYI 5ddd6b4425 home: vim: numbertoggle: use lua callbacks
Use `vim.opt` because those are local options (i.e: similar to `set` it
defaults to setting it locally, `vim.opt_local` is not necessary).
2024-07-18 20:21:13 +01:00
Bruno BELANYI 5ddb72e6c0 home: vim: signtoggle: fix toggling
Don't know how I missed this for so long...
2024-07-15 20:34:09 +01:00
2 changed files with 23 additions and 6 deletions

View file

@ -7,17 +7,28 @@ local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal rnu | endif",
callback = function()
if vim.opt.number:get() then
vim.opt.relativenumber = true
end
end,
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal nornu | endif",
callback = function()
if vim.opt.number:get() then
vim.opt.relativenumber = false
end
end,
})
-- Never show the sign column in a terminal buffer
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = "*",
group = numbertoggle,
command = "setlocal nonu nornu",
callback = function()
vim.opt.number = false
vim.opt.relativenumber = false
end,
})

View file

@ -4,17 +4,23 @@ local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
pattern = "*",
group = signtoggle,
command = "setlocal signcolumn=yes",
callback = function()
vim.opt.signcolumn = "yes"
end,
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
pattern = "*",
group = signtoggle,
command = "setlocal signcolumn=yes",
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,
command = "setlocal signcolumn=no",
callback = function()
vim.opt.signcolumn = "no"
end,
})