mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
feat: floating windows and notifications!
This commit is contained in:
parent
a0ba99f267
commit
9b2a06c5ce
@ -63,6 +63,51 @@ M.nav_file = function(id)
|
||||
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.fn.nvim_create_buf(false, true)
|
||||
local win_id = vim.fn.nvim_open_win(bufnr, true, options)
|
||||
|
||||
return {
|
||||
bufnr = bufnr,
|
||||
win_id = win_id,
|
||||
}
|
||||
end
|
||||
|
||||
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 M
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user