feat(cwd): do not cache the cwd for gitworktrees

This commit is contained in:
ThePrimeagen 2021-04-06 13:16:17 -06:00
parent a47beb5d10
commit 5a7d3a6ae8
2 changed files with 8 additions and 11 deletions

View File

@ -1,5 +1,4 @@
local Path = require("plenary.path") local Path = require("plenary.path")
local cwd = vim.loop.cwd()
local config_path = vim.fn.stdpath("config") local config_path = vim.fn.stdpath("config")
local data_path = vim.fn.stdpath("data") local data_path = vim.fn.stdpath("data")
local utils = require("harpoon.utils") local utils = require("harpoon.utils")
@ -54,8 +53,8 @@ end
local function ensure_correct_config(config) local function ensure_correct_config(config)
local projects = config.projects local projects = config.projects
if projects[cwd] == nil then if projects[vim.loop.cwd()] == nil then
projects[cwd] = { projects[vim.loop.cwd()] = {
mark = { mark = {
marks = {} marks = {}
}, },
@ -65,7 +64,7 @@ local function ensure_correct_config(config)
} }
end end
local proj = projects[cwd] local proj = projects[vim.loop.cwd()]
if proj.mark == nil then if proj.mark == nil then
proj.mark = {marks = {}} proj.mark = {marks = {}}
end end
@ -134,19 +133,19 @@ M.setup = function(config)
expand_dir(u_config), expand_dir(u_config),
expand_dir(config)) expand_dir(config))
-- There was this issue where the 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 cwd -- an object for vim.loop.cwd()
ensure_correct_config(complete_config) ensure_correct_config(complete_config)
HarpoonConfig = complete_config HarpoonConfig = complete_config
end end
M.get_term_config = function() M.get_term_config = function()
return HarpoonConfig.projects[cwd].term return HarpoonConfig.projects[vim.loop.cwd()].term
end end
M.get_mark_config = function() M.get_mark_config = function()
return HarpoonConfig.projects[cwd].mark return HarpoonConfig.projects[vim.loop.cwd()].mark
end end
M.get_menu_config = function() M.get_menu_config = function()

View File

@ -1,12 +1,10 @@
local Path = require("plenary.path") local Path = require("plenary.path")
local cwd = vim.loop.cwd()
local data_path = vim.fn.stdpath("data") local data_path = vim.fn.stdpath("data")
local M = { local M = {
cwd = cwd,
data_path = data_path, data_path = data_path,
normalize_path = function(item) normalize_path = function(item)
return Path:new(item):make_relative(cwd) return Path:new(item):make_relative(vim.loop.cwd())
end end
} }