mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
Merge pull request #15 from asbjornhaland/dead_code
feat(save): remove dead code to prevent nil value on save
This commit is contained in:
commit
9fbc24280d
@ -43,7 +43,7 @@ function merge_table_impl(t1, t2)
|
||||
end
|
||||
end
|
||||
|
||||
function merge_tables(...)
|
||||
function merge_tables(...)
|
||||
local out = {}
|
||||
for i = 2, select("#",...) do
|
||||
merge_table_impl(out, select(i, ...))
|
||||
@ -51,7 +51,7 @@ function merge_tables(...)
|
||||
return out
|
||||
end
|
||||
|
||||
function ensure_correct_config(config)
|
||||
function ensure_correct_config(config)
|
||||
local projects = config.projects
|
||||
if projects[cwd] == nil then
|
||||
projects[cwd] = {
|
||||
@ -73,7 +73,7 @@ function ensure_correct_config(config)
|
||||
end
|
||||
end
|
||||
|
||||
function expand_dir(config)
|
||||
function expand_dir(config)
|
||||
local projects = config.projects or {}
|
||||
local expanded_config = {}
|
||||
for k in pairs(projects) do
|
||||
@ -85,21 +85,11 @@ function expand_dir(config)
|
||||
end
|
||||
|
||||
M.save = function()
|
||||
local term_config = terminals.get_config()
|
||||
local mark_config = mark.get_config()
|
||||
|
||||
if not harpoon_config.projects[cwd] then
|
||||
harpoon_config.projects[cwd] = {}
|
||||
end
|
||||
|
||||
harpoon_config.projects[cwd].term = term_config
|
||||
harpoon_config.projects[cwd].mark = mark_config
|
||||
|
||||
Path:new(cache_config):write(vim.fn.json_encode(harpoon_config), 'w')
|
||||
end
|
||||
|
||||
-- 1. saved. Where do we save?
|
||||
M.setup = function(config)
|
||||
M.setup = function(config)
|
||||
function read_config(config)
|
||||
return vim.fn.json_decode(Path:new(config):read())
|
||||
end
|
||||
@ -119,10 +109,10 @@ M.setup = function(config)
|
||||
c_config = {}
|
||||
end
|
||||
|
||||
local complete_config =
|
||||
local complete_config =
|
||||
merge_tables(
|
||||
{projects = {}},
|
||||
expand_dir(c_config),
|
||||
{projects = {}},
|
||||
expand_dir(c_config),
|
||||
expand_dir(u_config),
|
||||
expand_dir(config))
|
||||
|
||||
@ -144,7 +134,7 @@ M.get_mark_config = function()
|
||||
end
|
||||
|
||||
-- should only be called for debug purposes
|
||||
M.print_config = function()
|
||||
M.print_config = function()
|
||||
print(vim.inspect(harpoon_config))
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user