revert nonfunctional changes

This commit is contained in:
Raigo Jerva 2021-05-02 10:04:00 +03:00
parent d8e2fcedf3
commit c245041e21
No known key found for this signature in database
GPG Key ID: 2156679E782853EC
4 changed files with 42 additions and 35 deletions

View File

@ -6,7 +6,7 @@
local M = {} local M = {}
M.reload = function() M.reload = function()
require("plenary.reload").reload_module("harpoon") require("plenary.reload").reload_module("harpoon");
end end
local function set_log_level() local function set_log_level()

View File

@ -28,7 +28,6 @@ local M = {}
... high level settings ... high level settings
} }
--]] --]]
HarpoonConfig = HarpoonConfig or {} HarpoonConfig = HarpoonConfig or {}
-- tbl_deep_extend does not work the way you would think -- tbl_deep_extend does not work the way you would think
@ -48,7 +47,7 @@ end
local function merge_tables(...) local function merge_tables(...)
local out = {} local out = {}
for i = 1, select("#", ...) do for i = 1, select("#",...) do
merge_table_impl(out, select(i, ...)) merge_table_impl(out, select(i, ...))
end end
log.trace("_merge_tables(): Output", out) log.trace("_merge_tables(): Output", out)
@ -62,10 +61,10 @@ local function ensure_correct_config(config)
log.trace("ensure_correct_config(): No config found for:", vim.loop.cwd()) log.trace("ensure_correct_config(): No config found for:", vim.loop.cwd())
projects[vim.loop.cwd()] = { projects[vim.loop.cwd()] = {
mark = { mark = {
marks = {}, marks = {}
}, },
term = { term = {
cmds = {}, cmds = {}
}, },
} }
end end
@ -86,7 +85,7 @@ local function ensure_correct_config(config)
local mark = marks[idx] local mark = marks[idx]
if type(mark) == "string" then if type(mark) == "string" then
mark = { mark = {
filename = mark, filename = mark
} }
marks[idx] = mark marks[idx] = mark
end end
@ -145,13 +144,17 @@ M.setup = function(config)
c_config = {} c_config = {}
end end
local complete_config = merge_tables({ local complete_config =
projects = {}, merge_tables({
global_settings = { projects = {},
["save_on_toggle"] = false, global_settings = {
["save_on_change"] = true, ["save_on_toggle"] = false,
["save_on_change"] = true,
},
}, },
}, expand_dir(c_config), expand_dir(u_config), expand_dir(config)) expand_dir(c_config),
expand_dir(u_config),
expand_dir(config))
-- There was this issue where the vim.loop.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 vim.loop.cwd() -- an object for vim.loop.cwd()

View File

@ -111,10 +111,10 @@ M.get_index_of = function(item)
return return
end end
if type(item) == "string" then if type(item) == 'string' then
local relative_item = utils.normalize_path(item) local relative_item = utils.normalize_path(item)
for idx = 1, M.get_length() do for idx = 1, M.get_length() do
if M.get_marked_file_name(idx) == relative_item then if M.get_marked_file_name(idx) == relative_item then
return idx return idx
end end
end end
@ -169,7 +169,7 @@ M.add_file = function(file_name_or_buf_id)
local found_idx = get_first_empty_slot() local found_idx = get_first_empty_slot()
harpoon.get_mark_config().marks[found_idx] = create_mark(buf_name) harpoon.get_mark_config().marks[found_idx] = create_mark(buf_name)
M.remove_empty_tail(false) M.remove_empty_tail(false)
emit_changed() emit_changed();
end end
-- _emit_on_changed == false should only be used internally -- _emit_on_changed == false should only be used internally
@ -201,7 +201,6 @@ M.store_offset = function()
local ok, res = pcall(function() local ok, res = pcall(function()
local buf_name = get_buf_name() local buf_name = get_buf_name()
local idx = M.get_index_of(buf_name) local idx = M.get_index_of(buf_name)
if not M.valid_index(idx) then if not M.valid_index(idx) then
return return
end end
@ -356,3 +355,5 @@ M.on = function(event, cb)
end end
return M return M

View File

@ -1,6 +1,6 @@
local harpoon = require("harpoon") local harpoon = require('harpoon')
local popup = require("popup") local popup = require('popup')
local Marked = require("harpoon.mark") local Marked = require('harpoon.mark')
local log = require("harpoon.dev").log local log = require("harpoon.dev").log
local M = {} local M = {}
@ -13,12 +13,12 @@ local function create_window()
local config = harpoon.get_menu_config() local config = harpoon.get_menu_config()
local width = config.width or 60 local width = config.width or 60
local height = config.height or 10 local height = config.height or 10
local borderchars = config.borderchars or { "", "", "", "", "", "", "", "" } local borderchars = config.borderchars or { '', '', '', '', '', '', '', '' }
local bufnr = vim.api.nvim_create_buf(false, false) local bufnr = vim.api.nvim_create_buf(false, false)
local Harpoon_win_id, win = popup.create(bufnr, { local Harpoon_win_id, win = popup.create(bufnr, {
title = "Harpoon", title = 'Harpoon',
highlight = "HarpoonWindow", highlight = 'HarpoonWindow',
line = math.floor(((vim.o.lines - height) / 2) - 1), line = math.floor(((vim.o.lines - height) / 2) - 1),
col = math.floor((vim.o.columns - width) / 2), col = math.floor((vim.o.columns - width) / 2),
minwidth = width, minwidth = width,
@ -26,7 +26,7 @@ local function create_window()
borderchars = borderchars, borderchars = borderchars,
}) })
vim.api.nvim_win_set_option(win.border.win_id, "winhl", "Normal:HarpoonBorder") vim.api.nvim_win_set_option(win.border.win_id, 'winhl', 'Normal:HarpoonBorder')
return { return {
bufnr = bufnr, bufnr = bufnr,
@ -40,7 +40,7 @@ local function get_menu_items()
local indices = {} local indices = {}
for idx = 1, #lines do for idx = 1, #lines do
local space_location = string.find(lines[idx], " ") local space_location = string.find(lines[idx], ' ')
log.trace("_get_menu_items():", idx, space_location) log.trace("_get_menu_items():", idx, space_location)
if space_location ~= nil then if space_location ~= nil then
@ -51,13 +51,15 @@ local function get_menu_items()
return indices return indices
end end
M.toggle_quick_menu = function() M.toggle_quick_menu = function()
log.info("toggle_quick_menu()") log.info("toggle_quick_menu()")
if Harpoon_win_id ~= nil and vim.api.nvim_win_is_valid(Harpoon_win_id) then if Harpoon_win_id ~= nil and vim.api.nvim_win_is_valid(Harpoon_win_id) then
local global_config = harpoon.get_global_settings() local global_config = harpoon.get_global_settings()
if global_config.save_on_toggle then if global_config.save_on_toggle then
require("harpoon.ui").on_menu_save() require('harpoon.ui').on_menu_save()
end end
vim.api.nvim_win_close(Harpoon_win_id, true) vim.api.nvim_win_close(Harpoon_win_id, true)
@ -122,14 +124,14 @@ end
function M.location_window(options) function M.location_window(options)
local default_options = { local default_options = {
relative = "editor", relative = 'editor',
style = "minimal", style = 'minimal',
width = 30, width = 30,
height = 15, height = 15,
row = 2, row = 2,
col = 2, col = 2,
} }
options = vim.tbl_extend("keep", options, default_options) options = vim.tbl_extend('keep', options, default_options)
local bufnr = options.bufnr or vim.fn.nvim_create_buf(false, true) local bufnr = options.bufnr or vim.fn.nvim_create_buf(false, true)
local win_id = vim.fn.nvim_open_win(bufnr, true, options) local win_id = vim.fn.nvim_open_win(bufnr, true, options)
@ -150,15 +152,15 @@ function M.notification(text)
width = 20, width = 20,
height = 2, height = 2,
row = 1, row = 1,
col = win_width - 21, col = win_width - 21
}) })
vim.api.nvim_buf_set_lines(info.bufnr, 0, 5, false, { "!!! Notification", text }) vim.api.nvim_buf_set_lines(info.bufnr, 0, 5, false, {"!!! Notification", text})
vim.api.nvim_set_current_win(prev_win) vim.api.nvim_set_current_win(prev_win)
return { return {
bufnr = info.bufnr, bufnr = info.bufnr,
win_id = info.win_id, win_id = info.win_id
} }
end end
@ -171,13 +173,13 @@ M.nav_next = function()
local current_index = Marked.get_current_index() local current_index = Marked.get_current_index()
local number_of_items = Marked.get_length() local number_of_items = Marked.get_length()
if current_index == nil then if current_index == nil then
current_index = 1 current_index = 1
else else
current_index = current_index + 1 current_index = current_index + 1
end end
if (current_index > number_of_items) then if (current_index > number_of_items) then
current_index = 1 current_index = 1
end end
M.nav_file(current_index) M.nav_file(current_index)
@ -188,13 +190,13 @@ M.nav_prev = function()
local current_index = Marked.get_current_index() local current_index = Marked.get_current_index()
local number_of_items = Marked.get_length() local number_of_items = Marked.get_length()
if current_index == nil then if current_index == nil then
current_index = number_of_items current_index = number_of_items
else else
current_index = current_index - 1 current_index = current_index - 1
end end
if (current_index < 1) then if (current_index < 1) then
current_index = number_of_items current_index = number_of_items
end end
@ -202,3 +204,4 @@ M.nav_prev = function()
end end
return M return M