summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/hooks.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/hooks.lua')
-rw-r--r--.config/nvim/lua/hooks.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/.config/nvim/lua/hooks.lua b/.config/nvim/lua/hooks.lua
index 0d5ed32..eaf0687 100644
--- a/.config/nvim/lua/hooks.lua
+++ b/.config/nvim/lua/hooks.lua
@@ -1,4 +1,8 @@
vim.api.nvim_create_autocmd({"BufWritePre"}, {
pattern = "*",
- command = [[%s/\s\+$//e]],
+ callback = function(ev)
+ save_cursor = vim.fn.getpos(".")
+ vim.cmd([[%s/\s\+$//e]])
+ vim.fn.setpos(".", save_cursor)
+ end,
})