summaryrefslogtreecommitdiff
path: root/pkgs/old-neovim/config/lua/autocommands.lua
diff options
context:
space:
mode:
authoroutremonde <outremonde@vivaldi.net>2025-06-10 20:32:00 -0400
committeroutremonde <outremonde@vivaldi.net>2025-06-10 20:32:00 -0400
commit9786eb8672213344d8d1b7bdef12bc94510b20db (patch)
treeb7d79440800c92d32187ab32c636b0830c94a610 /pkgs/old-neovim/config/lua/autocommands.lua
initialized repository
Former-commit-id: 84647f22b951a957b2b83885b612115d473f6626
Diffstat (limited to 'pkgs/old-neovim/config/lua/autocommands.lua')
-rw-r--r--pkgs/old-neovim/config/lua/autocommands.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/pkgs/old-neovim/config/lua/autocommands.lua b/pkgs/old-neovim/config/lua/autocommands.lua
new file mode 100644
index 0000000..85a58c6
--- /dev/null
+++ b/pkgs/old-neovim/config/lua/autocommands.lua
@@ -0,0 +1,36 @@
+-- Autocommands
+
+-- Use relative line number in normal mode and absolute in insert mode
+vim.opt.number = true
+local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", {})
+vim.api.nvim_create_autocmd(
+ { "BufEnter", "FocusGained", "InsertLeave", "WinEnter", "CmdlineLeave" },
+ {
+ group = numbertoggle,
+ callback = function()
+ if vim.opt.number and vim.api.nvim_get_mode() ~= "i" then
+ vim.opt.relativenumber = true
+ end
+ end,
+ }
+)
+
+vim.api.nvim_create_autocmd(
+ { "BufLeave", "FocusLost", "InsertEnter", "WinLeave", "CmdlineEnter" },
+ {
+ group = numbertoggle,
+ callback = function()
+ if vim.opt.number then
+ vim.opt.relativenumber = false
+ vim.cmd("redraw")
+ end
+ end,
+ }
+)
+
+ -- start terminal in insert mode
+vim.api.nvim_create_autocmd("TermOpen", {
+ callback = function()
+ vim.cmd "startinsert!"
+ end,
+})