mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
Change project_key to function
This commit is contained in:
parent
968b93cf76
commit
accf7ef4ef
@ -50,7 +50,7 @@ local function mark_config_key()
|
|||||||
if HarpoonConfig.mark_branch then
|
if HarpoonConfig.mark_branch then
|
||||||
return utils.branch_key()
|
return utils.branch_key()
|
||||||
else
|
else
|
||||||
return utils.project_key
|
return utils.project_key()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,9 +72,7 @@ local function ensure_correct_config(config)
|
|||||||
mark_config_key()
|
mark_config_key()
|
||||||
)
|
)
|
||||||
projects[mark_config_key()] = {
|
projects[mark_config_key()] = {
|
||||||
mark = {
|
mark = { marks = {} },
|
||||||
marks = {},
|
|
||||||
},
|
|
||||||
term = {
|
term = {
|
||||||
cmds = {},
|
cmds = {},
|
||||||
},
|
},
|
||||||
@ -102,9 +100,7 @@ local function ensure_correct_config(config)
|
|||||||
|
|
||||||
for idx, mark in pairs(marks) do
|
for idx, mark in pairs(marks) do
|
||||||
if type(mark) == "string" then
|
if type(mark) == "string" then
|
||||||
mark = {
|
mark = { filename = mark }
|
||||||
filename = mark,
|
|
||||||
}
|
|
||||||
marks[idx] = mark
|
marks[idx] = mark
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -197,7 +193,7 @@ function M.refresh_projects_b4update()
|
|||||||
cache_config
|
cache_config
|
||||||
)
|
)
|
||||||
-- save current runtime version of our project config for merging back in later
|
-- save current runtime version of our project config for merging back in later
|
||||||
local cwd = vim.loop.cwd()
|
local cwd = mark_config_key()
|
||||||
local current_p_config = {
|
local current_p_config = {
|
||||||
projects = {
|
projects = {
|
||||||
[cwd] = ensure_correct_config(HarpoonConfig).projects[cwd],
|
[cwd] = ensure_correct_config(HarpoonConfig).projects[cwd],
|
||||||
@ -241,7 +237,7 @@ end
|
|||||||
|
|
||||||
function M.get_term_config()
|
function M.get_term_config()
|
||||||
log.trace("get_term_config()")
|
log.trace("get_term_config()")
|
||||||
return ensure_correct_config(HarpoonConfig).projects[utils.project_key].term
|
return ensure_correct_config(HarpoonConfig).projects[utils.project_key()].term
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_mark_config()
|
function M.get_mark_config()
|
||||||
|
@ -4,17 +4,22 @@ local Job = require("plenary.job")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
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.project_key()
|
||||||
return string.gsub(vim.loop.cwd() .. '-' .. vim.fn.system('git branch --show-current'), "\n", "")
|
return vim.loop.cwd()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.branch_key()
|
||||||
|
return string.gsub(
|
||||||
|
vim.loop.cwd() .. "-" .. vim.fn.system("git branch --show-current"),
|
||||||
|
"\n",
|
||||||
|
""
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.normalize_path(item)
|
function M.normalize_path(item)
|
||||||
return Path:new(item):make_relative(M.branch_key)
|
return Path:new(item):make_relative(M.project_key())
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_os_command_output(cmd, cwd)
|
function M.get_os_command_output(cmd, cwd)
|
||||||
@ -24,20 +29,24 @@ function M.get_os_command_output(cmd, cwd)
|
|||||||
end
|
end
|
||||||
local command = table.remove(cmd, 1)
|
local command = table.remove(cmd, 1)
|
||||||
local stderr = {}
|
local stderr = {}
|
||||||
local stdout, ret = Job:new({
|
local stdout, ret = Job
|
||||||
command = command,
|
:new({
|
||||||
args = cmd,
|
command = command,
|
||||||
cwd = cwd,
|
args = cmd,
|
||||||
on_stderr = function(_, data)
|
cwd = cwd,
|
||||||
table.insert(stderr, data)
|
on_stderr = function(_, data)
|
||||||
end
|
table.insert(stderr, data)
|
||||||
}):sync()
|
end,
|
||||||
|
})
|
||||||
|
:sync()
|
||||||
return stdout, ret, stderr
|
return stdout, ret, stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.split_string(str, delimiter)
|
function M.split_string(str, delimiter)
|
||||||
local result = {}
|
local result = {}
|
||||||
for match in (str .. delimiter):gmatch("(.-)" .. delimiter) do table.insert(result, match) end
|
for match in (str .. delimiter):gmatch("(.-)" .. delimiter) do
|
||||||
|
table.insert(result, match)
|
||||||
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user