feat(offsets): Harp**n offsets

This commit is contained in:
ThePrimeagen 2021-03-23 10:56:19 -06:00
parent 1158df026f
commit d5229fb085
3 changed files with 15 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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