From ea31840c398477e9797553add6519e8bec5cd574 Mon Sep 17 00:00:00 2001 From: Brandon Conway Date: Sun, 14 Mar 2021 21:45:40 -0700 Subject: [PATCH 1/3] Add .editorconfig --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8529c8b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true From 2b83649583c4010f04696bdfad28947320a1ae3d Mon Sep 17 00:00:00 2001 From: Brandon Conway Date: Sun, 14 Mar 2021 21:46:55 -0700 Subject: [PATCH 2/3] Add dev reloader --- lua/harpoon/dev.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lua/harpoon/dev.lua diff --git a/lua/harpoon/dev.lua b/lua/harpoon/dev.lua new file mode 100644 index 0000000..192cef2 --- /dev/null +++ b/lua/harpoon/dev.lua @@ -0,0 +1,12 @@ +-- Don't include this file, we should manually include it via +-- require("harpoon.dev").reload(); +-- +-- A quick mapping can be setup using something like: +-- :nmap rr :lua require("harpoon.dev").reload() +local M = {} + +M.reload = function() + require("plenary.reload").reload_module("harpoon"); +end + +return M From df9050d40f0d8183d9031ecc28243c569864cef0 Mon Sep 17 00:00:00 2001 From: Brandon Conway Date: Sun, 14 Mar 2021 21:52:08 -0700 Subject: [PATCH 3/3] Save changes when closing menu --- lua/harpoon/mark.lua | 6 ++++++ lua/harpoon/ui.lua | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lua/harpoon/mark.lua b/lua/harpoon/mark.lua index 5abb927..8ce8a47 100644 --- a/lua/harpoon/mark.lua +++ b/lua/harpoon/mark.lua @@ -202,6 +202,12 @@ M.to_quickfix_list = function() vim.fn.setqflist(qf_list) end +M.set_mark_list = function(new_list) + local config = harpoon.get_mark_config() + + config.marks = new_list +end + M.to_quickfix_list() return M diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 21bc2ea..1e61860 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -21,8 +21,28 @@ function create_window() return win_info end +function get_menu_items() + local lines = vim.api.nvim_buf_get_lines(bufh, 0, -1, true) + local indices = {} + + for idx = 1, #lines do + local space_location = string.find(lines[idx], ' ') + + if space_location ~= nil then + table.insert(indices, string.sub(lines[idx], space_location + 1)) + end + end + + return indices +end + +local save_changes = function() + Marked.set_mark_list(get_menu_items()) +end + M.toggle_quick_menu = function() if win_id ~= nil and vim.api.nvim_win_is_valid(win_id) then + save_changes() vim.api.nvim_win_close(win_id, true) win_id = nil