mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
adjust log levels
- promote direct interactions to info - demote local functions to trace
This commit is contained in:
parent
51b7239577
commit
e06d8f1aea
@ -51,11 +51,12 @@ local function merge_tables(...)
|
||||
for i = 1, select("#", ...) do
|
||||
merge_table_impl(out, select(i, ...))
|
||||
end
|
||||
log.trace("_merge_tables(): Output", out)
|
||||
return out
|
||||
end
|
||||
|
||||
local function ensure_correct_config(config)
|
||||
log.debug("_ensure_correct_config()")
|
||||
log.trace("_ensure_correct_config()")
|
||||
local projects = config.projects
|
||||
if projects[vim.loop.cwd()] == nil then
|
||||
log.trace("ensure_correct_config(): No config found for:", vim.loop.cwd())
|
||||
@ -97,7 +98,7 @@ local function ensure_correct_config(config)
|
||||
end
|
||||
|
||||
local function expand_dir(config)
|
||||
log.debug("_expand_dir()")
|
||||
log.trace("_expand_dir()")
|
||||
log.trace("_expand_dir(): Config pre-expansion:", config)
|
||||
|
||||
local projects = config.projects or {}
|
||||
@ -119,7 +120,7 @@ M.save = function()
|
||||
end
|
||||
|
||||
local function read_config(local_config)
|
||||
log.debug("_read_config():", local_config)
|
||||
log.trace("_read_config():", local_config)
|
||||
return vim.fn.json_decode(Path:new(local_config):read())
|
||||
end
|
||||
|
||||
|
@ -10,24 +10,24 @@ local callbacks = {}
|
||||
-- I am trying to avoid over engineering the whole thing. We will likely only
|
||||
-- need one event emitted
|
||||
local function emit_changed()
|
||||
log.debug("_emit_changed()")
|
||||
log.trace("_emit_changed()")
|
||||
if harpoon.get_global_settings().save_on_change then
|
||||
harpoon.save()
|
||||
end
|
||||
|
||||
if not callbacks["changed"] then
|
||||
log.debug("_emit_changed(): no callbacks for 'changed', returning")
|
||||
log.trace("_emit_changed(): no callbacks for 'changed', returning")
|
||||
return
|
||||
end
|
||||
|
||||
for idx, cb in pairs(callbacks["changed"]) do
|
||||
log.debug(string.format("_emit_changed(): Running callback #%d for 'changed'", idx))
|
||||
log.trace(string.format("_emit_changed(): Running callback #%d for 'changed'", idx))
|
||||
cb()
|
||||
end
|
||||
end
|
||||
|
||||
local function filter_empty_string(list)
|
||||
log.debug("_filter_empty_string()")
|
||||
log.trace("_filter_empty_string()")
|
||||
local next = {}
|
||||
for idx = 1, #list do
|
||||
if list[idx] ~= "" then
|
||||
@ -39,7 +39,7 @@ local function filter_empty_string(list)
|
||||
end
|
||||
|
||||
local function get_first_empty_slot()
|
||||
log.debug("_get_first_empty_slot()")
|
||||
log.trace("_get_first_empty_slot()")
|
||||
for idx = 1, M.get_length() do
|
||||
local filename = M.get_marked_file_name(idx)
|
||||
if filename == "" then
|
||||
@ -51,7 +51,7 @@ local function get_first_empty_slot()
|
||||
end
|
||||
|
||||
local function get_buf_name(id)
|
||||
log.debug("_get_buf_name():", id)
|
||||
log.trace("_get_buf_name():", id)
|
||||
if id == nil then
|
||||
return utils.normalize_path(vim.fn.bufname(vim.fn.bufnr()))
|
||||
elseif type(id) == "string" then
|
||||
@ -84,7 +84,7 @@ local function create_mark(filename)
|
||||
end
|
||||
|
||||
local function mark_exists(buf_name)
|
||||
log.debug("_mark_exists()")
|
||||
log.trace("_mark_exists()")
|
||||
for idx = 1, M.get_length() do
|
||||
if M.get_marked_file_name(idx) == buf_name then
|
||||
log.trace("_mark_exists(): Mark exists", buf_name)
|
||||
@ -97,7 +97,7 @@ local function mark_exists(buf_name)
|
||||
end
|
||||
|
||||
local function validate_buf_name(buf_name)
|
||||
log.debug("_validate_buf_name():", buf_name)
|
||||
log.trace("_validate_buf_name():", buf_name)
|
||||
if buf_name == "" or buf_name == nil then
|
||||
log.error("_validate_buf_name(): Not a valid name for a mark,", buf_name)
|
||||
return
|
||||
@ -157,7 +157,7 @@ end
|
||||
|
||||
M.add_file = function(file_name_or_buf_id)
|
||||
local buf_name = get_buf_name(file_name_or_buf_id)
|
||||
log.debug("add_file():", buf_name)
|
||||
log.info("add_file():", buf_name)
|
||||
|
||||
if M.valid_index(M.get_index_of(buf_name)) then
|
||||
-- we don't alter file layout.
|
||||
@ -231,12 +231,12 @@ M.rm_file = function(file_name_or_buf_id)
|
||||
harpoon.get_mark_config().marks[idx] = create_mark("")
|
||||
M.remove_empty_tail(false)
|
||||
emit_changed()
|
||||
log.debug("rm_file(): Removed mark at id", idx)
|
||||
log.info("rm_file(): Removed mark at id", idx)
|
||||
end
|
||||
|
||||
M.clear_all = function()
|
||||
harpoon.get_mark_config().marks = {}
|
||||
log.debug("clear_all(): Clearing all marks.")
|
||||
log.info("clear_all(): Clearing all marks.")
|
||||
emit_changed()
|
||||
end
|
||||
|
||||
@ -265,7 +265,7 @@ M.set_current_at = function(idx)
|
||||
local buf_name = get_buf_name()
|
||||
local current_idx = M.get_index_of(buf_name)
|
||||
|
||||
log.debug("set_current_at(): Setting id", idx, buf_name)
|
||||
log.info("set_current_at(): Setting id", idx, buf_name)
|
||||
|
||||
-- Remove it if it already exists
|
||||
if M.valid_index(current_idx) then
|
||||
@ -324,18 +324,18 @@ end
|
||||
M.toggle_file = function(file_name_or_buf_id)
|
||||
local buf_name = get_buf_name(file_name_or_buf_id)
|
||||
|
||||
log.debug("toggle_file():", buf_name)
|
||||
log.info("toggle_file():", buf_name)
|
||||
|
||||
validate_buf_name(buf_name)
|
||||
|
||||
if (mark_exists(buf_name)) then
|
||||
M.rm_file(buf_name)
|
||||
print("Mark removed")
|
||||
log.trace("toggle_file(): Mark removed")
|
||||
log.debug("toggle_file(): Mark removed")
|
||||
else
|
||||
M.add_file(buf_name)
|
||||
print("Mark added")
|
||||
log.trace("toggle_file(): Mark added")
|
||||
log.debug("toggle_file(): Mark added")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ local M = {}
|
||||
local terminals = {}
|
||||
|
||||
local function create_terminal()
|
||||
log.debug("_create_terminal()")
|
||||
log.trace("_create_terminal()")
|
||||
local current_id = vim.fn.bufnr()
|
||||
|
||||
vim.cmd(":terminal")
|
||||
@ -32,7 +32,7 @@ function getCmd(idx)
|
||||
end
|
||||
|
||||
local function find_terminal(idx)
|
||||
log.debug("_find_terminal(): Terminal:", idx)
|
||||
log.trace("_find_terminal(): Terminal:", idx)
|
||||
local term_handle = terminals[idx]
|
||||
if not term_handle or not vim.api.nvim_buf_is_valid(term_handle.buf_id) then
|
||||
local buf_id, term_id = create_terminal()
|
||||
@ -50,14 +50,14 @@ local function find_terminal(idx)
|
||||
end
|
||||
|
||||
M.gotoTerminal = function(idx)
|
||||
log.debug("gotoTerminal(): Terminal:", idx)
|
||||
log.info("gotoTerminal(): Terminal:", idx)
|
||||
local term_handle = find_terminal(idx)
|
||||
|
||||
vim.api.nvim_set_current_buf(term_handle.buf_id)
|
||||
end
|
||||
|
||||
M.sendCommand = function(idx, cmd, ...)
|
||||
log.debug("sendCommand(): Terminal:", idx)
|
||||
log.info("sendCommand(): Terminal:", idx)
|
||||
local term_handle = find_terminal(idx)
|
||||
|
||||
if type(cmd) == "number" then
|
||||
|
@ -9,7 +9,7 @@ Harpoon_win_id = nil
|
||||
Harpoon_bufh = nil
|
||||
|
||||
local function create_window()
|
||||
log.debug("_create_window()")
|
||||
log.trace("_create_window()")
|
||||
local config = harpoon.get_menu_config()
|
||||
local width = config.width or 60
|
||||
local height = config.height or 10
|
||||
@ -35,7 +35,7 @@ local function create_window()
|
||||
end
|
||||
|
||||
local function get_menu_items()
|
||||
log.debug("_get_menu_items()")
|
||||
log.trace("_get_menu_items()")
|
||||
local lines = vim.api.nvim_buf_get_lines(Harpoon_bufh, 0, -1, true)
|
||||
local indices = {}
|
||||
|
||||
@ -52,7 +52,7 @@ local function get_menu_items()
|
||||
end
|
||||
|
||||
M.toggle_quick_menu = function()
|
||||
log.debug("toggle_quick_menu()")
|
||||
log.info("toggle_quick_menu()")
|
||||
if Harpoon_win_id ~= nil and vim.api.nvim_win_is_valid(Harpoon_win_id) then
|
||||
local global_config = harpoon.get_global_settings()
|
||||
|
||||
@ -97,7 +97,7 @@ M.on_menu_save = function()
|
||||
end
|
||||
|
||||
M.nav_file = function(id)
|
||||
log.debug("nav_file(): Navigating to", id)
|
||||
log.info("nav_file(): Navigating to", id)
|
||||
local idx = Marked.get_index_of(id)
|
||||
if not Marked.valid_index(idx) then
|
||||
log.debug("nav_file(): No mark exists for id", id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user