2023-05-06 19:17:16 +02:00
|
|
|
-- Show lines numbers
|
|
|
|
vim.opt.number = true
|
2021-02-23 16:04:47 +01:00
|
|
|
|
2023-05-06 19:17:16 +02:00
|
|
|
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true })
|
2021-02-23 16:04:47 +01:00
|
|
|
|
2023-05-06 19:17:16 +02:00
|
|
|
-- Toggle numbers between relative and absolute when changing buffers
|
|
|
|
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
|
|
|
pattern = "*",
|
|
|
|
group = numbertoggle,
|
2024-07-15 21:40:37 +02:00
|
|
|
callback = function()
|
|
|
|
if vim.opt.number:get() then
|
|
|
|
vim.opt.relativenumber = true
|
|
|
|
end
|
|
|
|
end,
|
2023-05-06 19:17:16 +02:00
|
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
|
|
|
pattern = "*",
|
|
|
|
group = numbertoggle,
|
2024-07-15 21:40:37 +02:00
|
|
|
callback = function()
|
|
|
|
if vim.opt.number:get() then
|
|
|
|
vim.opt.relativenumber = false
|
|
|
|
end
|
|
|
|
end,
|
2023-05-06 19:17:16 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
-- Never show the sign column in a terminal buffer
|
|
|
|
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
|
|
|
pattern = "*",
|
|
|
|
group = numbertoggle,
|
2024-07-15 21:40:37 +02:00
|
|
|
callback = function()
|
|
|
|
vim.opt.number = false
|
|
|
|
vim.opt.relativenumber = false
|
|
|
|
end,
|
2023-05-06 19:17:16 +02:00
|
|
|
})
|