mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
Merge branch 'master' into gh-actions
This commit is contained in:
commit
9a2486de43
25
README.md
25
README.md
@ -161,22 +161,17 @@ require("harpoon").setup({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
-- This uses the wildcard api, you can check it out via branch wildcards
|
|
||||||
-- not quite ready yet for mainline.
|
|
||||||
-- Wildcards are to be used in conjunction with git worktrees (at least
|
|
||||||
-- that is my goal)
|
|
||||||
["/home/theprimeagen/personal/harpoon/{}"] = {
|
|
||||||
term = {
|
|
||||||
cmds = {
|
|
||||||
"echo hello {}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Debugging
|
## 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.)
|
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.
|
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.
|
||||||
|
@ -9,8 +9,8 @@ M.reload = function()
|
|||||||
require("plenary.reload").reload_module("harpoon")
|
require("plenary.reload").reload_module("harpoon")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local log_levels = { "trace", "debug", "info", "warn", "error", "fatal" }
|
||||||
local function set_log_level()
|
local function set_log_level()
|
||||||
local log_levels = { "trace", "debug", "info", "warn", "error", "fatal" }
|
|
||||||
local log_level = vim.env.HARPOON_LOG or vim.g.harpoon_log_level
|
local log_level = vim.env.HARPOON_LOG or vim.g.harpoon_log_level
|
||||||
|
|
||||||
for _, level in pairs(log_levels) do
|
for _, level in pairs(log_levels) do
|
||||||
@ -22,9 +22,27 @@ local function set_log_level()
|
|||||||
return "warn" -- default, if user hasn't set to one from log_levels
|
return "warn" -- default, if user hasn't set to one from log_levels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local log_level = set_log_level()
|
||||||
M.log = require("plenary.log").new({
|
M.log = require("plenary.log").new({
|
||||||
plugin = "harpoon",
|
plugin = "harpoon",
|
||||||
level = set_log_level(),
|
level = log_level,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local log_key = os.time()
|
||||||
|
|
||||||
|
local function override(key)
|
||||||
|
local fn = M.log[key]
|
||||||
|
M.log[key] = function(...)
|
||||||
|
fn(log_key, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in pairs(log_levels) do
|
||||||
|
override(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.get_log_key = function()
|
||||||
|
return log_key
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local Path = require("plenary.path")
|
local Path = require("plenary.path")
|
||||||
local utils = require("harpoon.utils")
|
local utils = require("harpoon.utils")
|
||||||
local log = require("harpoon.dev").log
|
local Dev = require("harpoon.dev")
|
||||||
|
local log = Dev.log
|
||||||
|
|
||||||
local config_path = vim.fn.stdpath("config")
|
local config_path = vim.fn.stdpath("config")
|
||||||
local data_path = vim.fn.stdpath("data")
|
local data_path = vim.fn.stdpath("data")
|
||||||
@ -158,6 +159,7 @@ M.setup = function(config)
|
|||||||
|
|
||||||
HarpoonConfig = complete_config
|
HarpoonConfig = complete_config
|
||||||
log.debug("setup(): Complete config", HarpoonConfig)
|
log.debug("setup(): Complete config", HarpoonConfig)
|
||||||
|
log.trace("setup(): log_key", Dev.get_log_key())
|
||||||
end
|
end
|
||||||
|
|
||||||
M.get_global_settings = function()
|
M.get_global_settings = function()
|
||||||
|
@ -87,10 +87,16 @@ M.toggle_quick_menu = function()
|
|||||||
vim.api.nvim_buf_set_option(Harpoon_bufh, "filetype", "harpoon")
|
vim.api.nvim_buf_set_option(Harpoon_bufh, "filetype", "harpoon")
|
||||||
vim.api.nvim_buf_set_option(Harpoon_bufh, "buftype", "acwrite")
|
vim.api.nvim_buf_set_option(Harpoon_bufh, "buftype", "acwrite")
|
||||||
vim.api.nvim_buf_set_option(Harpoon_bufh, "bufhidden", "delete")
|
vim.api.nvim_buf_set_option(Harpoon_bufh, "bufhidden", "delete")
|
||||||
|
vim.api.nvim_buf_set_keymap(Harpoon_bufh, "n", "<CR>", ":lua require('harpoon.ui').on_norm_enter()<CR>", {})
|
||||||
vim.cmd(string.format("autocmd BufWriteCmd <buffer=%s> :lua require('harpoon.ui').on_menu_save()", Harpoon_bufh))
|
vim.cmd(string.format("autocmd BufWriteCmd <buffer=%s> :lua require('harpoon.ui').on_menu_save()", Harpoon_bufh))
|
||||||
vim.cmd(string.format("autocmd BufModifiedSet <buffer=%s> set nomodified", Harpoon_bufh))
|
vim.cmd(string.format("autocmd BufModifiedSet <buffer=%s> set nomodified", Harpoon_bufh))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.on_norm_enter = function()
|
||||||
|
local idx = vim.fn.line('.')
|
||||||
|
M.nav_file(idx)
|
||||||
|
end
|
||||||
|
|
||||||
M.on_menu_save = function()
|
M.on_menu_save = function()
|
||||||
log.trace("on_menu_save()")
|
log.trace("on_menu_save()")
|
||||||
Marked.set_mark_list(get_menu_items())
|
Marked.set_mark_list(get_menu_items())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
augroup THE_PRIMEAGEN_HARPOON
|
augroup THE_PRIMEAGEN_HARPOON
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
autocmd BufLeave,VimLeave * :lua require('harpoon.mark').store_offset()
|
||||||
augroup END
|
augroup END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user