Merge pull request #33 from brandoncc/add-file-toggling

Add file toggling
This commit is contained in:
ThePrimeagen 2021-03-16 18:38:34 -06:00 committed by GitHub
commit a6faacee32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,8 +115,8 @@ M.store_offset = function()
local line = vim.api.nvim_eval("line('.')");
end
M.rm_file = function()
local buf_name = get_buf_name()
M.rm_file = function(file_name_or_buf_id)
local buf_name = get_buf_name(file_name_or_buf_id)
local idx = M.get_index_of(buf_name)
if not M.valid_index(idx) then
@ -177,6 +177,21 @@ M.set_mark_list = function(new_list)
config.marks = new_list
end
M.toggle_file = function(file_name_or_buf_id)
local mark_count_before = #harpoon.get_mark_config().marks
M.add_file(file_name_or_buf_id)
local mark_count_after = #harpoon.get_mark_config().marks
if (mark_count_before == mark_count_after) then
M.rm_file(file_name_or_buf_id)
print("Mark removed")
else
print("Mark Added")
end
end
M.to_quickfix_list()
return M