mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
refactor(ui): use 'number' option in quick_menu like in cmd-ui
This commit is contained in:
parent
22b2650315
commit
f227419697
@ -1,5 +1,6 @@
|
||||
local harpoon = require("harpoon")
|
||||
local popup = require("plenary.popup")
|
||||
local utils = require("harpoon.utils")
|
||||
local log = require("harpoon.dev").log
|
||||
local term = require("harpoon.term")
|
||||
|
||||
@ -53,17 +54,13 @@ local function create_window()
|
||||
}
|
||||
end
|
||||
|
||||
local function is_white_space(str)
|
||||
return str:gsub("%s", "") == ""
|
||||
end
|
||||
|
||||
local function get_menu_items()
|
||||
log.trace("_get_menu_items()")
|
||||
local lines = vim.api.nvim_buf_get_lines(Harpoon_cmd_bufh, 0, -1, true)
|
||||
local indices = {}
|
||||
|
||||
for _, line in pairs(lines) do
|
||||
if not is_white_space(line) then
|
||||
if not utils.is_white_space(line) then
|
||||
table.insert(indices, line)
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
local harpoon = require("harpoon")
|
||||
local popup = require("plenary.popup")
|
||||
local Marked = require("harpoon.mark")
|
||||
local utils = require("harpoon.utils")
|
||||
local log = require("harpoon.dev").log
|
||||
|
||||
local M = {}
|
||||
@ -60,12 +61,9 @@ local function get_menu_items()
|
||||
local lines = vim.api.nvim_buf_get_lines(Harpoon_bufh, 0, -1, true)
|
||||
local indices = {}
|
||||
|
||||
for idx = 1, #lines do
|
||||
local space_location = string.find(lines[idx], " ")
|
||||
log.debug("_get_menu_items():", idx, space_location)
|
||||
|
||||
if space_location ~= nil then
|
||||
table.insert(indices, string.sub(lines[idx], space_location + 1))
|
||||
for _, line in pairs(lines) do
|
||||
if not utils.is_white_space(line) then
|
||||
table.insert(indices, line)
|
||||
end
|
||||
end
|
||||
|
||||
@ -91,9 +89,10 @@ M.toggle_quick_menu = function()
|
||||
if file == "" then
|
||||
file = "(empty)"
|
||||
end
|
||||
contents[idx] = string.format("%d %s", idx, file)
|
||||
contents[idx] = string.format("%s", file)
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_option(Harpoon_win_id, "number", true)
|
||||
vim.api.nvim_buf_set_name(Harpoon_bufh, "harpoon-menu")
|
||||
vim.api.nvim_buf_set_lines(Harpoon_bufh, 0, #contents, false, contents)
|
||||
vim.api.nvim_buf_set_option(Harpoon_bufh, "filetype", "harpoon")
|
||||
|
@ -6,6 +6,9 @@ local M = {
|
||||
normalize_path = function(item)
|
||||
return Path:new(item):make_relative(vim.loop.cwd())
|
||||
end,
|
||||
is_white_space = function(str)
|
||||
return str:gsub("%s", "") == ""
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
||||
|
Loading…
x
Reference in New Issue
Block a user