mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-17 19:40:23 +00:00
fix: navigation
This commit is contained in:
parent
ec03b3cc4b
commit
e2e582e776
@ -16,6 +16,19 @@ local function get_harpoon_menu_name()
|
|||||||
return HARPOON_MENU .. harpoon_menu_id
|
return HARPOON_MENU .. harpoon_menu_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.run_select_command()
|
||||||
|
local harpoon = require("harpoon")
|
||||||
|
harpoon.logger:log('select by keymap \'<CR>\'')
|
||||||
|
harpoon.ui:select_menu_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.run_toggle_command(key)
|
||||||
|
local harpoon = require("harpoon")
|
||||||
|
harpoon.logger:log('toggle by keymap \'' .. key .. '\'')
|
||||||
|
harpoon.ui:select_menu_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---TODO: I don't know how to do what i want to do, but i want to be able to
|
---TODO: I don't know how to do what i want to do, but i want to be able to
|
||||||
---make this so we use callbacks for these buffer actions instead of using
|
---make this so we use callbacks for these buffer actions instead of using
|
||||||
---strings back into the ui. it feels gross and it puts odd coupling
|
---strings back into the ui. it feels gross and it puts odd coupling
|
||||||
@ -45,21 +58,21 @@ function M.setup_autocmds_and_keymaps(bufnr)
|
|||||||
bufnr,
|
bufnr,
|
||||||
"n",
|
"n",
|
||||||
"q",
|
"q",
|
||||||
"<Cmd>lua require('harpoon').logger:log('toggle by keymap \'q\''); require('harpoon').ui:toggle_quick_menu()<CR>",
|
"<Cmd>lua require('harpoon.buffer').run_toggle_command('q')<CR>",
|
||||||
{ silent = true }
|
{ silent = true }
|
||||||
)
|
)
|
||||||
vim.api.nvim_buf_set_keymap(
|
vim.api.nvim_buf_set_keymap(
|
||||||
bufnr,
|
bufnr,
|
||||||
"n",
|
"n",
|
||||||
"<ESC>",
|
"<ESC>",
|
||||||
"<Cmd>lua require('harpoon').logger:log('toggle by keymap \'<Esc>\''); require('harpoon').ui:toggle_quick_menu()<CR>",
|
"<Cmd>lua require('harpoon.buffer').run_toggle_command('<ESC>')<CR>",
|
||||||
{ silent = true }
|
{ silent = true }
|
||||||
)
|
)
|
||||||
vim.api.nvim_buf_set_keymap(
|
vim.api.nvim_buf_set_keymap(
|
||||||
bufnr,
|
bufnr,
|
||||||
"n",
|
"n",
|
||||||
"<CR>",
|
"<CR>",
|
||||||
"<Cmd>lua require('harpoon').logger:log('select by keymap \'<CR>\''); require('harpoon').ui:select_menu_item()<CR>",
|
"<Cmd>lua require('harpoon.buffer').run_select_command()<CR>",
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +11,12 @@ local DEFAULT_WINDOW_WIDTH = 69 -- nice
|
|||||||
---@field active_list HarpoonList
|
---@field active_list HarpoonList
|
||||||
local HarpoonUI = {}
|
local HarpoonUI = {}
|
||||||
|
|
||||||
|
---@param list HarpoonList
|
||||||
|
---@return string
|
||||||
|
local function list_name(list)
|
||||||
|
return list and list.name or "nil"
|
||||||
|
end
|
||||||
|
|
||||||
HarpoonUI.__index = HarpoonUI
|
HarpoonUI.__index = HarpoonUI
|
||||||
|
|
||||||
---@param settings HarpoonSettings
|
---@param settings HarpoonSettings
|
||||||
@ -25,21 +31,13 @@ function HarpoonUI:new(settings)
|
|||||||
}, self)
|
}, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_name(list)
|
|
||||||
if list ~= nil then
|
|
||||||
return list.name
|
|
||||||
end
|
|
||||||
|
|
||||||
return "(list nil)"
|
|
||||||
end
|
|
||||||
|
|
||||||
function HarpoonUI:close_menu()
|
function HarpoonUI:close_menu()
|
||||||
if self.closing then
|
if self.closing then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.closing = true
|
self.closing = true
|
||||||
Logger:log("ui#close_menu name: ", get_name(self.active_list), "win and bufnr", {
|
Logger:log("ui#close_menu name: ", list_name(self.active_list), "win and bufnr", {
|
||||||
win = self.win_id,
|
win = self.win_id,
|
||||||
bufnr = self.bufnr
|
bufnr = self.bufnr
|
||||||
})
|
})
|
||||||
@ -152,59 +150,4 @@ function HarpoonUI:configure(settings)
|
|||||||
self.settings = settings
|
self.settings = settings
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
function M.location_window(options)
|
|
||||||
local default_options = {
|
|
||||||
relative = "editor",
|
|
||||||
style = "minimal",
|
|
||||||
width = 30,
|
|
||||||
height = 15,
|
|
||||||
row = 2,
|
|
||||||
col = 2,
|
|
||||||
}
|
|
||||||
options = vim.tbl_extend("keep", options, default_options)
|
|
||||||
|
|
||||||
local bufnr = options.bufnr or vim.api.nvim_create_buf(false, true)
|
|
||||||
local win_id = vim.api.nvim_open_win(bufnr, true, options)
|
|
||||||
|
|
||||||
return {
|
|
||||||
bufnr = bufnr,
|
|
||||||
win_id = win_id,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: What is this used for?
|
|
||||||
function M.notification(text)
|
|
||||||
local win_stats = vim.api.nvim_list_uis()[1]
|
|
||||||
local win_width = win_stats.width
|
|
||||||
|
|
||||||
local prev_win = vim.api.nvim_get_current_win()
|
|
||||||
|
|
||||||
local info = M.location_window({
|
|
||||||
width = 20,
|
|
||||||
height = 2,
|
|
||||||
row = 1,
|
|
||||||
col = win_width - 21,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
info.bufnr,
|
|
||||||
0,
|
|
||||||
5,
|
|
||||||
false,
|
|
||||||
{ "!!! Notification", text }
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_current_win(prev_win)
|
|
||||||
|
|
||||||
return {
|
|
||||||
bufnr = info.bufnr,
|
|
||||||
win_id = info.win_id,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.close_notification(bufnr)
|
|
||||||
vim.api.nvim_buf_delete(bufnr)
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
|
|
||||||
return HarpoonUI
|
return HarpoonUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user