mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
feat(offsets): Harp**n offsets
This commit is contained in:
parent
1158df026f
commit
d5229fb085
@ -149,7 +149,8 @@ M.store_offset = function()
|
||||
return
|
||||
end
|
||||
|
||||
local row, col = vim.api.nvim_eval("line('.')");
|
||||
harpoon.get_mark_config().marks[idx].row =
|
||||
vim.fn.line(".");
|
||||
end)
|
||||
|
||||
if not ok then
|
||||
|
@ -9,7 +9,7 @@ local M = {}
|
||||
win_id = nil
|
||||
bufh = nil
|
||||
|
||||
function create_window()
|
||||
local function create_window()
|
||||
local win_info = float.percentage_range_window(
|
||||
factorw,
|
||||
factorh,
|
||||
@ -82,16 +82,13 @@ M.nav_file = function(id)
|
||||
return
|
||||
end
|
||||
|
||||
local buf_id = vim.fn.bufnr(Marked.get_marked_file_name(idx))
|
||||
local mark = Marked.get_marked_file(idx)
|
||||
local buf_id = vim.fn.bufnr(mark.filename)
|
||||
local set_row = not vim.api.nvim_buf_is_loaded(buf_id)
|
||||
|
||||
if vim.api.nvim_win_is_valid(buf_id) then
|
||||
vim.api.nvim_win_close(win_id)
|
||||
end
|
||||
|
||||
if buf_id ~= nil and buf_id ~= -1 then
|
||||
vim.api.nvim_set_current_buf(buf_id)
|
||||
else
|
||||
vim.cmd(string.format("e %s", Marked.get_marked_file(idx)))
|
||||
vim.api.nvim_set_current_buf(buf_id)
|
||||
if set_row and mark.row then
|
||||
vim.cmd(string.format(":%d", mark.row))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
fun! HarpoonLeave()
|
||||
lua require('harpoon.mark').store_offset()
|
||||
lua require('harpoon').save()
|
||||
endfun
|
||||
|
||||
augroup THE_PRIMEAGEN_HARPOON
|
||||
autocmd!
|
||||
autocmd VimLeavePre * :lua require('harpoon').save()
|
||||
autocmd VimLeavePre * :call HarpoonLeave()
|
||||
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
||||
augroup END
|
||||
|
Loading…
x
Reference in New Issue
Block a user