From 02e91845bb7a9e88447e6ab2c1c187dca3d4e2ac Mon Sep 17 00:00:00 2001 From: Pranav Rao <56097527+pranavrao145@users.noreply.github.com> Date: Tue, 23 Nov 2021 14:42:42 -0500 Subject: [PATCH] refactor(cleanup): cleaned up some code in term and tmux modules Also styled init.lua. --- lua/harpoon/init.lua | 8 +------- lua/harpoon/term.lua | 1 + lua/harpoon/tmux.lua | 7 +++++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 9af279d..735e294 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -160,13 +160,7 @@ M.setup = function(config) ["tmux_autoclose_windows"] = false, ["excluded_filetypes"] = { "harpoon" }, }, - }, expand_dir( - c_config - ), expand_dir( - u_config - ), expand_dir( - config - )) + }, expand_dir(c_config), expand_dir(u_config), expand_dir(config)) -- There was this issue where the vim.loop.cwd() didn't have marks or term, but had -- an object for vim.loop.cwd() diff --git a/lua/harpoon/term.lua b/lua/harpoon/term.lua index e0a8c5d..0a0681c 100644 --- a/lua/harpoon/term.lua +++ b/lua/harpoon/term.lua @@ -40,6 +40,7 @@ local function find_terminal(args) if not term_handle or not vim.api.nvim_buf_is_valid(term_handle.buf_id) then local buf_id, term_id = create_terminal(args.create_with) if buf_id == nil then + error("Failed to find and create terminal.") return end diff --git a/lua/harpoon/tmux.lua b/lua/harpoon/tmux.lua index 1229acf..06c168e 100644 --- a/lua/harpoon/tmux.lua +++ b/lua/harpoon/tmux.lua @@ -51,6 +51,8 @@ local function terminal_exists(window_id) "list-windows", }, vim.loop.cwd()) + -- This has to be done this way because tmux has-session does not give + -- updated results for _, line in pairs(window_list) do local window_info = utils.split_string(line, "@")[1] @@ -80,6 +82,7 @@ local function find_terminal(args) local window_id = create_terminal() if window_id == nil then + error("Failed to find and create tmux window.") return end @@ -107,7 +110,7 @@ M.gotoTerminal = function(idx) log.trace("tmux: gotoTerminal(): Window:", idx) local window_handle = find_terminal(idx) - local _, _, _ = utils.get_os_command_output({ + utils.get_os_command_output({ "tmux", "select-window", "-t", @@ -146,7 +149,7 @@ M.clear_all = function() for _, window in pairs(tmux_windows) do -- Delete the current tmux window - local _, _, _ = utils.get_os_command_output({ + utils.get_os_command_output({ "tmux", "kill-window", "-t",