diff --git a/README.md b/README.md index de29113..831dd8d 100644 --- a/README.md +++ b/README.md @@ -176,5 +176,7 @@ require("harpoon").setup({ ``` +## Debugging +Harpoon writes logs to a `harpoon.log` file that resides in Neovim's cache path. (`:echo stdpath("cache")` to find where that is for you.) - +By default, logging is enabled for warnings and above. This can be changed by setting `vim.g.harpoon_log_level` variable to one of the following log levels: `trace`, `debug`, `info`, `warn`, `error`, or `fatal`. Note that this would have to be done **before** harpoon's `setup` call. Alternatively, it can be more convenient to launch Neovim with an environment variable, e.g. `> HARPOON_LOG=trace nvim`. In case both, `vim.g` and an environment variable are used, the log level set by the environment variable overrules. Supplying an invalid log level defaults back to warnings. diff --git a/lua/harpoon/dev.lua b/lua/harpoon/dev.lua index 913da23..07b985d 100644 --- a/lua/harpoon/dev.lua +++ b/lua/harpoon/dev.lua @@ -10,8 +10,8 @@ M.reload = function() end local function set_log_level() - local log_levels = { "trace", "debug", "info", "warning", "error", "fatal" } - local log_level = vim.g.harpoon_log_level or vim.env.HARPOON_LOG + local log_levels = { "trace", "debug", "info", "warn", "error", "fatal" } + local log_level = vim.env.HARPOON_LOG or vim.g.harpoon_log_level for _, level in pairs(log_levels) do if level == log_level then diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index c0b3c77..951f3ea 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -145,16 +145,14 @@ M.setup = function(config) end local complete_config = - merge_tables({ - projects = {}, - global_settings = { + merge_tables( + {projects = {} , global_settings = { ["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 -- an object for vim.loop.cwd() @@ -193,3 +191,4 @@ end M.setup() return M + diff --git a/lua/harpoon/term.lua b/lua/harpoon/term.lua index 99bacb9..b317cea 100644 --- a/lua/harpoon/term.lua +++ b/lua/harpoon/term.lua @@ -1,4 +1,5 @@ -local harpoon = require("harpoon") +local harpoon = require('harpoon') +local Path = require("plenary.path") local log = require("harpoon.dev").log local M = {} @@ -10,7 +11,7 @@ local function create_terminal() vim.cmd(":terminal") local buf_id = vim.fn.bufnr() - local term_id = vim.b.terminal_job_id + local term_id = vim.b.terminal_job_id if term_id == nil then log.error("_create_terminal(): term_id is nil") @@ -20,7 +21,7 @@ local function create_terminal() -- Make sure the term buffer has "hidden" set so it doesn't get thrown -- away and cause an error - vim.api.nvim_buf_set_option(buf_id, "bufhidden", "hide") + vim.api.nvim_buf_set_option(buf_id, 'bufhidden', 'hide') -- Resets the buffer back to the old one vim.api.nvim_set_current_buf(current_id) @@ -42,7 +43,7 @@ local function find_terminal(idx) term_handle = { buf_id = buf_id, - term_id = term_id, + term_id = term_id } terminals[idx] = term_handle end diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 57da256..4e0e889 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -169,7 +169,7 @@ function M.close_notification(bufnr) end M.nav_next = function() - log.debug("nav_next()") + log.info("nav_next()") local current_index = Marked.get_current_index() local number_of_items = Marked.get_length() @@ -186,7 +186,7 @@ M.nav_next = function() end M.nav_prev = function() - log.debug("nav_prev()") + log.info("nav_prev()") local current_index = Marked.get_current_index() local number_of_items = Marked.get_length()