Skip to content

Commit

Permalink
Add autocommand to keep z-mark as prev location
Browse files Browse the repository at this point in the history
  • Loading branch information
handdara committed Dec 6, 2024
1 parent 1d1523a commit 45a79ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 11 additions & 0 deletions fst/him/nvim-nrw/lua/handdara/config/autocommands.lua
Original file line number Diff line number Diff line change
@@ -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
15 changes: 5 additions & 10 deletions fst/him/nvim-nrw/lua/handdara/config/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ return function()
map('n', "<C-b>", "<C-W>-")
map('n', "<C-=>", "<C-W>=")

map('n', "<C-a>", "mz'A`z") -- "quick-use" global marks
map('n', "<C-s>", "mz'S`z")
map('n', "<C-d>", "mz'D`z")
map('n', "<C-f>", "mz'F`z")
map('n', "<C-g>", "mz'G`z")
map('n', "<C-S-a>", "mA")
map('n', "<C-S-s>", "mS")
map('n', "<C-S-d>", "mD")
map('n', "<C-S-f>", "mF")
map('n', "<C-S-g>", "mG")
map('n', "<C-S-a>", "'A`z") -- "quick-use" global marks
map('n', "<C-S-s>", "'S`z")
map('n', "<C-S-d>", "'D`z")
map('n', "<C-S-f>", "'F`z")
map('n', "<C-S-g>", "'G`z")

-- Diagnostic keymaps
map('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
Expand Down
2 changes: 2 additions & 0 deletions fst/him/nvim-nrw/lua/handdara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 45a79ac

Please sign in to comment.