mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 10:00:29 +00:00
chore: style
This commit is contained in:
parent
047cd66d6f
commit
574a642204
@ -1,4 +1,2 @@
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
return augroup("Harpoon", {})
|
||||
|
||||
|
||||
|
@ -21,16 +21,15 @@ end
|
||||
---@param bufnr number
|
||||
function M.setup_autocmds_and_keymaps(bufnr)
|
||||
local curr_file = vim.api.nvim_buf_get_name(0)
|
||||
local cmd =
|
||||
string.format(
|
||||
"autocmd Filetype harpoon "
|
||||
.. "let path = '%s' | call clearmatches() | "
|
||||
-- move the cursor to the line containing the current filename
|
||||
.. "call search('\\V'.path.'\\$') | "
|
||||
-- add a hl group to that line
|
||||
.. "call matchadd('HarpoonCurrentFile', '\\V'.path.'\\$')",
|
||||
curr_file:gsub("\\", "\\\\")
|
||||
)
|
||||
local cmd = string.format(
|
||||
"autocmd Filetype harpoon "
|
||||
.. "let path = '%s' | call clearmatches() | "
|
||||
-- move the cursor to the line containing the current filename
|
||||
.. "call search('\\V'.path.'\\$') | "
|
||||
-- add a hl group to that line
|
||||
.. "call matchadd('HarpoonCurrentFile', '\\V'.path.'\\$')",
|
||||
curr_file:gsub("\\", "\\\\")
|
||||
)
|
||||
vim.cmd(cmd)
|
||||
|
||||
if vim.api.nvim_buf_get_name(bufnr) == "" then
|
||||
@ -90,7 +89,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
|
||||
vim.schedule(function()
|
||||
require("harpoon").ui:toggle_quick_menu()
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufLeave" }, {
|
||||
@ -98,7 +97,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
|
||||
pattern = "__harpoon*",
|
||||
callback = function()
|
||||
require("harpoon").ui:toggle_quick_menu()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,6 @@ local function normalize_path(buf_name)
|
||||
return Path:new(buf_name):make_relative(vim.loop.cwd())
|
||||
end
|
||||
|
||||
|
||||
local M = {}
|
||||
|
||||
---@alias HarpoonListItem {value: any, context: any}
|
||||
@ -133,7 +132,11 @@ function M.get_default_config()
|
||||
-- path, if that is the case we can use the context to
|
||||
-- store the bufname and then have value be the normalized
|
||||
-- value
|
||||
or normalize_path(vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()))
|
||||
or normalize_path(
|
||||
vim.api.nvim_buf_get_name(
|
||||
vim.api.nvim_get_current_buf()
|
||||
)
|
||||
)
|
||||
|
||||
local bufnr = vim.fn.bufnr(name, false)
|
||||
|
||||
|
@ -26,7 +26,6 @@ function M.set_data_path(path)
|
||||
end
|
||||
|
||||
local function has_keys(t)
|
||||
|
||||
-- luacheck: ignore 512
|
||||
for _ in pairs(t) do
|
||||
return true
|
||||
|
@ -50,7 +50,6 @@ function Harpoon:setup(partial_config)
|
||||
---TODO: should we go through every seen list and update its config?
|
||||
|
||||
if self.hooks_setup == false then
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
|
||||
group = HarpoonGroup,
|
||||
pattern = "*",
|
||||
@ -145,5 +144,3 @@ function Harpoon:__debug_reset()
|
||||
end
|
||||
|
||||
return Harpoon:new()
|
||||
|
||||
|
||||
|
@ -72,7 +72,6 @@ describe("harpoon", function()
|
||||
|
||||
eq(list:length(), 3)
|
||||
eq(created_files, list:display())
|
||||
|
||||
end)
|
||||
|
||||
it("using :q to leave harpoon should quit everything", function()
|
||||
@ -85,12 +84,11 @@ describe("harpoon", function()
|
||||
eq(vim.api.nvim_win_is_valid(win_id), true)
|
||||
eq(vim.api.nvim_get_current_buf(), bufnr)
|
||||
|
||||
vim.cmd [[ q! ]] -- TODO: I shouldn't need q! here
|
||||
vim.cmd([[ q! ]]) -- TODO: I shouldn't need q! here
|
||||
|
||||
eq(vim.api.nvim_buf_is_valid(bufnr), false)
|
||||
eq(vim.api.nvim_win_is_valid(win_id), false)
|
||||
eq(harpoon.ui.bufnr, nil)
|
||||
eq(harpoon.ui.win_id, nil)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
@ -39,7 +39,10 @@ function HarpoonUI:close_menu()
|
||||
vim.api.nvim_win_close(self.win_id, true)
|
||||
end
|
||||
|
||||
if self.border_win_id ~= nil and vim.api.nvim_win_is_valid(self.border_win_id) then
|
||||
if
|
||||
self.border_win_id ~= nil
|
||||
and vim.api.nvim_win_is_valid(self.border_win_id)
|
||||
then
|
||||
vim.api.nvim_win_close(self.border_win_id, true)
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.is_white_space(str)
|
||||
|
Loading…
x
Reference in New Issue
Block a user