From 322d07be58b551d31f35af7f604c660c1a849d41 Mon Sep 17 00:00:00 2001 From: ThePrimeagen Date: Mon, 22 Feb 2021 11:14:46 -0700 Subject: [PATCH] fix again nil issues --- lua/harpoon/init.lua | 4 ++-- lua/harpoon/mark.lua | 14 ++++++++++---- lua/harpoon/term.lua | 14 ++++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 99545d5..3eafa6f 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -132,8 +132,8 @@ M.setup = function(config) -- an object for cwd ensure_correct_config(complete_config) - terminals.setup(complete_config) - mark.setup(complete_config) + terminals.setup(complete_config.projects[cwd].term) + mark.setup(complete_config.projects[cwd].mark) harpoon_config = complete_config end diff --git a/lua/harpoon/mark.lua b/lua/harpoon/mark.lua index 134c7b4..54e5e8d 100644 --- a/lua/harpoon/mark.lua +++ b/lua/harpoon/mark.lua @@ -14,10 +14,16 @@ function get_id_or_current_buffer(id) end M.setup = function(config) - if not config.projects[cwd] then - mark_config = {marks = {}} - else - mark_config = config.projects[cwd].mark + mark_config = config + if mark_config.marks == nil then + + -- resetting the mark config if there is an issue loading the config + -- this can hide errors. + -- + -- TODO: create a logging mechanism to get these values + mark_config = { + marks = {} + } end end diff --git a/lua/harpoon/term.lua b/lua/harpoon/term.lua index 27a326f..69f3f9c 100644 --- a/lua/harpoon/term.lua +++ b/lua/harpoon/term.lua @@ -64,11 +64,17 @@ end } } --]] + M.setup = function(config) - if not config.projects[cwd] then - terminal_config = {} - else - terminal_config = config.projects[cwd].term + terminal_config = config + if terminal_config.cmds == nil then + + -- Resets terminal config if there is some missing values. + -- + -- TODO: create a logging mechanism to get these values + terminal_config = { + cmds = {} + } end end