Skip to content

Commit

Permalink
feat(nvim): create autocmds for setting relative linenumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
KirkEasterson committed Sep 12, 2024
1 parent 6f3d4c5 commit 09920fd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nvim/.config/nvim/lua/kirk/core/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,24 @@ autocmd("BufWritePost", {
end,
once = false,
})

local num_toggle_autgroup = augroup("numbertoggle", {})
autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
pattern = "*",
group = num_toggle_autgroup,
callback = function()
if vim.o.nu then
vim.opt.relativenumber = true
end
end,
})

autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
pattern = "*",
group = num_toggle_autgroup,
callback = function()
if vim.o.nu then
vim.opt.relativenumber = false
end
end,
})

0 comments on commit 09920fd

Please sign in to comment.