mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-16 11:00:23 +00:00
Merge pull request #18 from anott03/anott
feat: floating windows and notifications!
This commit is contained in:
commit
6935f70d78
@ -63,6 +63,51 @@ M.nav_file = function(id)
|
|||||||
end
|
end
|
||||||
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
|
return M
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user