mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
Add config to mark git branch
This commit is contained in:
parent
60167d9b18
commit
968b93cf76
@ -46,6 +46,14 @@ local function merge_table_impl(t1, t2)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function mark_config_key()
|
||||||
|
if HarpoonConfig.mark_branch then
|
||||||
|
return utils.branch_key()
|
||||||
|
else
|
||||||
|
return utils.project_key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function merge_tables(...)
|
local function merge_tables(...)
|
||||||
log.trace("_merge_tables()")
|
log.trace("_merge_tables()")
|
||||||
local out = {}
|
local out = {}
|
||||||
@ -58,12 +66,12 @@ end
|
|||||||
local function ensure_correct_config(config)
|
local function ensure_correct_config(config)
|
||||||
log.trace("_ensure_correct_config()")
|
log.trace("_ensure_correct_config()")
|
||||||
local projects = config.projects
|
local projects = config.projects
|
||||||
if projects[utils.mark_config_key()] == nil then
|
if projects[mark_config_key()] == nil then
|
||||||
log.debug(
|
log.debug(
|
||||||
"ensure_correct_config(): No config found for:",
|
"ensure_correct_config(): No config found for:",
|
||||||
utils.mark_config_key()
|
mark_config_key()
|
||||||
)
|
)
|
||||||
projects[utils.mark_config_key()] = {
|
projects[mark_config_key()] = {
|
||||||
mark = {
|
mark = {
|
||||||
marks = {},
|
marks = {},
|
||||||
},
|
},
|
||||||
@ -73,11 +81,11 @@ local function ensure_correct_config(config)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local proj = projects[utils.mark_config_key()]
|
local proj = projects[mark_config_key()]
|
||||||
if proj.mark == nil then
|
if proj.mark == nil then
|
||||||
log.debug(
|
log.debug(
|
||||||
"ensure_correct_config(): No marks found for",
|
"ensure_correct_config(): No marks found for",
|
||||||
utils.mark_config_key()
|
mark_config_key()
|
||||||
)
|
)
|
||||||
proj.mark = { marks = {} }
|
proj.mark = { marks = {} }
|
||||||
end
|
end
|
||||||
@ -85,7 +93,7 @@ local function ensure_correct_config(config)
|
|||||||
if proj.term == nil then
|
if proj.term == nil then
|
||||||
log.debug(
|
log.debug(
|
||||||
"ensure_correct_config(): No terminal commands found for",
|
"ensure_correct_config(): No terminal commands found for",
|
||||||
utils.mark_config_key()
|
mark_config_key()
|
||||||
)
|
)
|
||||||
proj.term = { cmds = {} }
|
proj.term = { cmds = {} }
|
||||||
end
|
end
|
||||||
@ -238,7 +246,7 @@ end
|
|||||||
|
|
||||||
function M.get_mark_config()
|
function M.get_mark_config()
|
||||||
log.trace("get_mark_config()")
|
log.trace("get_mark_config()")
|
||||||
return ensure_correct_config(HarpoonConfig).projects[utils.mark_config_key()].mark
|
return ensure_correct_config(HarpoonConfig).projects[mark_config_key()].mark
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_menu_config()
|
function M.get_menu_config()
|
||||||
|
@ -4,7 +4,9 @@ local Job = require("plenary.job")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.project_key = vim.loop.cwd()
|
local project_key = vim.loop.cwd()
|
||||||
|
M.project_key = project_key
|
||||||
|
M.branch_key = vim.loop.cwd()
|
||||||
M.data_path = data_path
|
M.data_path = data_path
|
||||||
|
|
||||||
function M.mark_config_key()
|
function M.mark_config_key()
|
||||||
@ -12,7 +14,7 @@ function M.mark_config_key()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.normalize_path(item)
|
function M.normalize_path(item)
|
||||||
return Path:new(item):make_relative(M.project_key)
|
return Path:new(item):make_relative(M.branch_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_os_command_output(cmd, cwd)
|
function M.get_os_command_output(cmd, cwd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user