fix: addresses #346 and #345

This commit is contained in:
mpaulson 2023-11-30 20:12:04 -07:00
parent 574adeb96d
commit 047cd66d6f
3 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,9 @@
local Path = require("plenary.path")
local function normalize_path(buf_name)
return Path:new(buf_name):make_relative(vim.loop.cwd())
end
local M = {}
---@alias HarpoonListItem {value: any, context: any}
@ -127,7 +133,7 @@ function M.get_default_config()
-- path, if that is the case we can use the context to
-- store the bufname and then have value be the normalized
-- value
or vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
or normalize_path(vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()))
local bufnr = vim.fn.bufnr(name, false)

View File

@ -43,6 +43,10 @@ function HarpoonList:length()
return #self.items
end
function HarpoonList:clear()
self.items = {}
end
---@return HarpoonList
function HarpoonList:append(item)
item = item or self.config.add()

View File

@ -1,9 +1,5 @@
local Path = require("plenary.path")
local M = {}
function M.normalize_path(item)
return Path:new(item):make_relative(M.project_key())
end
function M.is_white_space(str)
return str:gsub("%s", "") == ""