Bruno BELANYI
5ddd6b4425
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).
35 lines
973 B
Lua
35 lines
973 B
Lua
-- Show lines numbers
|
|
vim.opt.number = true
|
|
|
|
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true })
|
|
|
|
-- Toggle numbers between relative and absolute when changing buffers
|
|
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
|
pattern = "*",
|
|
group = numbertoggle,
|
|
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,
|
|
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,
|
|
callback = function()
|
|
vim.opt.number = false
|
|
vim.opt.relativenumber = false
|
|
end,
|
|
})
|