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).
This commit is contained in:
parent
d101ae56f2
commit
eb80441f49
|
@ -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,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue