mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-17 19:40:23 +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
|
||||||
end
|
end
|
||||||
|
|
||||||
function merge_tables(...)
|
function merge_tables(...)
|
||||||
local out = {}
|
local out = {}
|
||||||
for i = 2, select("#",...) do
|
for i = 2, select("#",...) do
|
||||||
merge_table_impl(out, select(i, ...))
|
merge_table_impl(out, select(i, ...))
|
||||||
@ -51,7 +51,7 @@ function merge_tables(...)
|
|||||||
return out
|
return out
|
||||||
end
|
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] = {
|
||||||
@ -73,7 +73,7 @@ function ensure_correct_config(config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function expand_dir(config)
|
function expand_dir(config)
|
||||||
local projects = config.projects or {}
|
local projects = config.projects or {}
|
||||||
local expanded_config = {}
|
local expanded_config = {}
|
||||||
for k in pairs(projects) do
|
for k in pairs(projects) do
|
||||||
@ -85,21 +85,11 @@ function expand_dir(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.save = function()
|
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')
|
Path:new(cache_config):write(vim.fn.json_encode(harpoon_config), 'w')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 1. saved. Where do we save?
|
-- 1. saved. Where do we save?
|
||||||
M.setup = function(config)
|
M.setup = function(config)
|
||||||
function read_config(config)
|
function read_config(config)
|
||||||
return vim.fn.json_decode(Path:new(config):read())
|
return vim.fn.json_decode(Path:new(config):read())
|
||||||
end
|
end
|
||||||
@ -119,10 +109,10 @@ M.setup = function(config)
|
|||||||
c_config = {}
|
c_config = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local complete_config =
|
local complete_config =
|
||||||
merge_tables(
|
merge_tables(
|
||||||
{projects = {}},
|
{projects = {}},
|
||||||
expand_dir(c_config),
|
expand_dir(c_config),
|
||||||
expand_dir(u_config),
|
expand_dir(u_config),
|
||||||
expand_dir(config))
|
expand_dir(config))
|
||||||
|
|
||||||
@ -144,7 +134,7 @@ M.get_mark_config = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- should only be called for debug purposes
|
-- should only be called for debug purposes
|
||||||
M.print_config = function()
|
M.print_config = function()
|
||||||
print(vim.inspect(harpoon_config))
|
print(vim.inspect(harpoon_config))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user