Skip to content

Commit

Permalink
Merge pull request #46 from jesseleite/customize-menu-window-yayaya
Browse files Browse the repository at this point in the history
Customizable menu window
  • Loading branch information
ThePrimeagen authored Mar 25, 2021
2 parents 7ca5c1d + 8e966d6 commit abb717f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
4 changes: 4 additions & 0 deletions lua/harpoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ M.get_mark_config = function()
return HarpoonConfig.projects[cwd].mark
end

M.get_menu_config = function()
return HarpoonConfig.menu or {}
end

-- should only be called for debug purposes
M.print_config = function()
print(vim.inspect(HarpoonConfig))
Expand Down
36 changes: 24 additions & 12 deletions lua/harpoon/ui.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
local float = require('plenary.window.float')
local harpoon = require('harpoon')
local popup = require('popup')
local Marked = require('harpoon.mark')

local factorw = 0.42069
local factorh = 0.69420

local M = {}

win_id = nil
bufh = nil

local function create_window()
local win_info = float.percentage_range_window(
factorw,
factorh,
{
winblend = 0
})
function create_window()
local config = harpoon.get_menu_config()
local width = config.width or 60
local height = config.height or 10
local borderchars = config.borderchars or { '', '', '', '', '', '', '', '' }
local bufnr = vim.api.nvim_create_buf(false, false)

local win_id, win = popup.create(bufnr, {
title = 'Harpoon',
highlight = 'HarpoonWindow',
line = math.floor(((vim.o.lines - height) / 2) - 1),
col = math.floor((vim.o.columns - width) / 2),
minwidth = width,
minheight = height,
borderchars = borderchars,
})

vim.api.nvim_win_set_option(win.border.win_id, 'winhl', 'Normal:HarpoonBorder')

return win_info
return {
bufnr = bufnr,
win_id = win_id,
}
end

local function get_menu_items()
Expand Down
3 changes: 3 additions & 0 deletions plugin/harpoon.vim
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ fun! Harpoon_SendTerminalCommand(ctrlId, command)
call term_sendkeys(l:bufh, a:command)
endif
endfun

highlight default HarpoonWindow ctermbg=none
highlight default HarpoonBorder ctermbg=none ctermfg=white

0 comments on commit abb717f

Please sign in to comment.