From 45a79ac4d5a609db38098ffd397d1e929c2030cb Mon Sep 17 00:00:00 2001 From: handdara Date: Fri, 6 Dec 2024 17:59:14 -0500 Subject: [PATCH] Add autocommand to keep z-mark as prev location --- .../nvim-nrw/lua/handdara/config/autocommands.lua | 11 +++++++++++ fst/him/nvim-nrw/lua/handdara/config/keymap.lua | 15 +++++---------- fst/him/nvim-nrw/lua/handdara/init.lua | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 fst/him/nvim-nrw/lua/handdara/config/autocommands.lua diff --git a/fst/him/nvim-nrw/lua/handdara/config/autocommands.lua b/fst/him/nvim-nrw/lua/handdara/config/autocommands.lua new file mode 100644 index 0000000..b55716f --- /dev/null +++ b/fst/him/nvim-nrw/lua/handdara/config/autocommands.lua @@ -0,0 +1,11 @@ +return function() + -- use register `z` as last location + local zmark_group = vim.api.nvim_create_augroup('ZMarkPrevLoc', { clear = true }) + vim.api.nvim_create_autocmd('BufLeave', { + callback = function() + vim.cmd [[mark z]] + end, + group = zmark_group, + pattern = '*', + }) +end diff --git a/fst/him/nvim-nrw/lua/handdara/config/keymap.lua b/fst/him/nvim-nrw/lua/handdara/config/keymap.lua index 50f6f43..ce9f7df 100644 --- a/fst/him/nvim-nrw/lua/handdara/config/keymap.lua +++ b/fst/him/nvim-nrw/lua/handdara/config/keymap.lua @@ -28,16 +28,11 @@ return function() map('n', "", "-") map('n', "", "=") - map('n', "", "mz'A`z") -- "quick-use" global marks - map('n', "", "mz'S`z") - map('n', "", "mz'D`z") - map('n', "", "mz'F`z") - map('n', "", "mz'G`z") - map('n', "", "mA") - map('n', "", "mS") - map('n', "", "mD") - map('n', "", "mF") - map('n', "", "mG") + map('n', "", "'A`z") -- "quick-use" global marks + map('n', "", "'S`z") + map('n', "", "'D`z") + map('n', "", "'F`z") + map('n', "", "'G`z") -- Diagnostic keymaps map('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) diff --git a/fst/him/nvim-nrw/lua/handdara/init.lua b/fst/him/nvim-nrw/lua/handdara/init.lua index 0d77942..0fce938 100644 --- a/fst/him/nvim-nrw/lua/handdara/init.lua +++ b/fst/him/nvim-nrw/lua/handdara/init.lua @@ -2,11 +2,13 @@ local hset = require 'handdara.config.set' local hkeymap = require 'handdara.config.keymap' local hcmds = require 'handdara.config.commands' local hlooks = require 'handdara.config.looks' +local hautocmds = require 'handdara.config.autocommands' local function setup(opts) hset() hkeymap() hcmds() + hautocmds() local col = opts.colorscheme if type(col) == 'string' then hlooks.init_looks(col)