mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
refactor(cleanup): cleaned up some code in term and tmux modules
Also styled init.lua.
This commit is contained in:
parent
51d68e2ec6
commit
02e91845bb
@ -160,13 +160,7 @@ M.setup = function(config)
|
|||||||
["tmux_autoclose_windows"] = false,
|
["tmux_autoclose_windows"] = false,
|
||||||
["excluded_filetypes"] = { "harpoon" },
|
["excluded_filetypes"] = { "harpoon" },
|
||||||
},
|
},
|
||||||
}, expand_dir(
|
}, expand_dir(c_config), expand_dir(u_config), expand_dir(config))
|
||||||
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
|
-- There was this issue where the vim.loop.cwd() didn't have marks or term, but had
|
||||||
-- an object for vim.loop.cwd()
|
-- an object for vim.loop.cwd()
|
||||||
|
@ -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
|
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)
|
local buf_id, term_id = create_terminal(args.create_with)
|
||||||
if buf_id == nil then
|
if buf_id == nil then
|
||||||
|
error("Failed to find and create terminal.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ local function terminal_exists(window_id)
|
|||||||
"list-windows",
|
"list-windows",
|
||||||
}, vim.loop.cwd())
|
}, 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
|
for _, line in pairs(window_list) do
|
||||||
local window_info = utils.split_string(line, "@")[1]
|
local window_info = utils.split_string(line, "@")[1]
|
||||||
|
|
||||||
@ -80,6 +82,7 @@ local function find_terminal(args)
|
|||||||
local window_id = create_terminal()
|
local window_id = create_terminal()
|
||||||
|
|
||||||
if window_id == nil then
|
if window_id == nil then
|
||||||
|
error("Failed to find and create tmux window.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -107,7 +110,7 @@ M.gotoTerminal = function(idx)
|
|||||||
log.trace("tmux: gotoTerminal(): Window:", idx)
|
log.trace("tmux: gotoTerminal(): Window:", idx)
|
||||||
local window_handle = find_terminal(idx)
|
local window_handle = find_terminal(idx)
|
||||||
|
|
||||||
local _, _, _ = utils.get_os_command_output({
|
utils.get_os_command_output({
|
||||||
"tmux",
|
"tmux",
|
||||||
"select-window",
|
"select-window",
|
||||||
"-t",
|
"-t",
|
||||||
@ -146,7 +149,7 @@ M.clear_all = function()
|
|||||||
|
|
||||||
for _, window in pairs(tmux_windows) do
|
for _, window in pairs(tmux_windows) do
|
||||||
-- Delete the current tmux window
|
-- Delete the current tmux window
|
||||||
local _, _, _ = utils.get_os_command_output({
|
utils.get_os_command_output({
|
||||||
"tmux",
|
"tmux",
|
||||||
"kill-window",
|
"kill-window",
|
||||||
"-t",
|
"-t",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user