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
280829b54f
commit
a7c542784c
|
@ -7,17 +7,28 @@ local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = numbertoggle,
|
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" }, {
|
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = numbertoggle,
|
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
|
-- Never show the sign column in a terminal buffer
|
||||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = numbertoggle,
|
group = numbertoggle,
|
||||||
command = "setlocal nonu nornu",
|
callback = function()
|
||||||
|
vim.opt.number = false
|
||||||
|
vim.opt.relativenumber = false
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue