mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-16 11:00:23 +00:00
commit
a48aa25640
@ -30,21 +30,48 @@ local M = {}
|
|||||||
--]]
|
--]]
|
||||||
harpoon_config = harpoon_config or {}
|
harpoon_config = harpoon_config or {}
|
||||||
|
|
||||||
|
-- tbl_deep_extend does not work the way you would think
|
||||||
|
function merge_table_impl(t1, t2)
|
||||||
|
for k, v in pairs(t2) do
|
||||||
|
if type(v) == "table" then
|
||||||
|
if type(t1[k]) == "table" then
|
||||||
|
merge_table_impl(t1[k], v)
|
||||||
|
else
|
||||||
|
t1[k] = v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
t1[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function merge_tables(...)
|
||||||
|
local out = {}
|
||||||
|
for i = 2, select("#",...) do
|
||||||
|
merge_table_impl(out, select(i, ...))
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
function ensure_correct_config(config)
|
function ensure_correct_config(config)
|
||||||
local projects = config.projects
|
local projects = config.projects
|
||||||
if projects[cwd] == nil then
|
if projects[cwd] == nil then
|
||||||
projects[cwd] = {
|
projects[cwd] = {
|
||||||
marks = {},
|
mark = {
|
||||||
term = {},
|
marks = {}
|
||||||
|
},
|
||||||
|
term = {
|
||||||
|
cmds = {}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if projects[cwd].marks == nil then
|
if projects[cwd].mark == nil then
|
||||||
projects[cwd].marks = {}
|
projects[cwd].mark = {marks = {}}
|
||||||
end
|
end
|
||||||
|
|
||||||
if projects[cwd].term == nil then
|
if projects[cwd].term == nil then
|
||||||
projects[cwd].term = {}
|
projects[cwd].term = {cmds = {}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,7 +122,7 @@ M.setup = function(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local complete_config =
|
local complete_config =
|
||||||
vim.tbl_deep_extend("force",
|
merge_tables(
|
||||||
{projects = {}},
|
{projects = {}},
|
||||||
expand_dir(c_config),
|
expand_dir(c_config),
|
||||||
expand_dir(u_config),
|
expand_dir(u_config),
|
||||||
@ -110,5 +137,13 @@ M.setup = function(config)
|
|||||||
harpoon_config = complete_config
|
harpoon_config = complete_config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- should only be called for debug purposes
|
||||||
|
M.print_config = function()
|
||||||
|
print(vim.inspect(harpoon_config))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sets a default config with no values
|
||||||
|
M.setup({projects = {}})
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
augroup THE_PRIMEAGEN_HARPOON
|
|
||||||
autocmd!
|
|
||||||
autocmd VimLeave * :lua require('harpoon').save()
|
|
||||||
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
|
||||||
augroup END
|
|
@ -1,5 +1,5 @@
|
|||||||
augroup THE_PRIMEAGEN_HARPOON
|
augroup THE_PRIMEAGEN_HARPOON
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimLeave * :lua require('harpoon').save()
|
autocmd VimLeavePre * :lua require('harpoon').save()
|
||||||
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
||||||
augroup END
|
augroup END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user