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
|
local augroup = vim.api.nvim_create_augroup
|
||||||
return augroup("Harpoon", {})
|
return augroup("Harpoon", {})
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ end
|
|||||||
---@param bufnr number
|
---@param bufnr number
|
||||||
function M.setup_autocmds_and_keymaps(bufnr)
|
function M.setup_autocmds_and_keymaps(bufnr)
|
||||||
local curr_file = vim.api.nvim_buf_get_name(0)
|
local curr_file = vim.api.nvim_buf_get_name(0)
|
||||||
local cmd =
|
local cmd = string.format(
|
||||||
string.format(
|
|
||||||
"autocmd Filetype harpoon "
|
"autocmd Filetype harpoon "
|
||||||
.. "let path = '%s' | call clearmatches() | "
|
.. "let path = '%s' | call clearmatches() | "
|
||||||
-- move the cursor to the line containing the current filename
|
-- move the cursor to the line containing the current filename
|
||||||
@ -90,7 +89,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
|
|||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
require("harpoon").ui:toggle_quick_menu()
|
require("harpoon").ui:toggle_quick_menu()
|
||||||
end)
|
end)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufLeave" }, {
|
vim.api.nvim_create_autocmd({ "BufLeave" }, {
|
||||||
@ -98,7 +97,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
|
|||||||
pattern = "__harpoon*",
|
pattern = "__harpoon*",
|
||||||
callback = function()
|
callback = function()
|
||||||
require("harpoon").ui:toggle_quick_menu()
|
require("harpoon").ui:toggle_quick_menu()
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ local function normalize_path(buf_name)
|
|||||||
return Path:new(buf_name):make_relative(vim.loop.cwd())
|
return Path:new(buf_name):make_relative(vim.loop.cwd())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@alias HarpoonListItem {value: any, context: any}
|
---@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
|
-- path, if that is the case we can use the context to
|
||||||
-- store the bufname and then have value be the normalized
|
-- store the bufname and then have value be the normalized
|
||||||
-- value
|
-- 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)
|
local bufnr = vim.fn.bufnr(name, false)
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ function M.set_data_path(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function has_keys(t)
|
local function has_keys(t)
|
||||||
|
|
||||||
-- luacheck: ignore 512
|
-- luacheck: ignore 512
|
||||||
for _ in pairs(t) do
|
for _ in pairs(t) do
|
||||||
return true
|
return true
|
||||||
|
@ -50,7 +50,6 @@ function Harpoon:setup(partial_config)
|
|||||||
---TODO: should we go through every seen list and update its config?
|
---TODO: should we go through every seen list and update its config?
|
||||||
|
|
||||||
if self.hooks_setup == false then
|
if self.hooks_setup == false then
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
|
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
|
||||||
group = HarpoonGroup,
|
group = HarpoonGroup,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
@ -145,5 +144,3 @@ function Harpoon:__debug_reset()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return Harpoon:new()
|
return Harpoon:new()
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ describe("harpoon", function()
|
|||||||
|
|
||||||
eq(list:length(), 3)
|
eq(list:length(), 3)
|
||||||
eq(created_files, list:display())
|
eq(created_files, list:display())
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("using :q to leave harpoon should quit everything", function()
|
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_win_is_valid(win_id), true)
|
||||||
eq(vim.api.nvim_get_current_buf(), bufnr)
|
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_buf_is_valid(bufnr), false)
|
||||||
eq(vim.api.nvim_win_is_valid(win_id), false)
|
eq(vim.api.nvim_win_is_valid(win_id), false)
|
||||||
eq(harpoon.ui.bufnr, nil)
|
eq(harpoon.ui.bufnr, nil)
|
||||||
eq(harpoon.ui.win_id, nil)
|
eq(harpoon.ui.win_id, nil)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
@ -39,7 +39,10 @@ function HarpoonUI:close_menu()
|
|||||||
vim.api.nvim_win_close(self.win_id, true)
|
vim.api.nvim_win_close(self.win_id, true)
|
||||||
end
|
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)
|
vim.api.nvim_win_close(self.border_win_id, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.is_white_space(str)
|
function M.is_white_space(str)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user