-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitbuf.lua
More file actions
35 lines (35 loc) · 1.28 KB
/
Copy pathsplitbuf.lua
File metadata and controls
35 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local M={conf={options={
r={desc='ranger',action=function() require'small.ranger'.run() end},
f={desc='shell',action=vim.fn.termopen},
s={
desc='scratch',
action=function ()
local buf=vim.api.nvim_create_buf(true,true)
vim.api.nvim_set_option_value('bufhidden','wipe',{buf=buf})
vim.api.nvim_win_set_buf(vim.api.nvim_get_current_win(),buf)
end
}
}}}
function M.open()
if M.conf.call then
M.conf.call()
return
end
local buf=vim.api.nvim_create_buf(false,true)
vim.api.nvim_set_option_value('bufhidden','wipe',{buf=buf})
local win=vim.api.nvim_open_win(buf,false,{
relative='win',width=math.max(vim.fn.winwidth(0)-50,20),height=math.max(vim.fn.winheight(0)-10,10),col=30,row=5,
focusable=false,style='minimal',noautocmd=true})
vim.wo[win].winblend=50
for k,v in pairs(M.conf.options) do
vim.api.nvim_buf_set_lines(buf,0,0,false,{k..' : '..v.desc})
end
vim.cmd.redraw()
local char=vim.fn.getcharstr()
vim.api.nvim_win_close(win,true)
if M.conf.options[char] then M.conf.options[char].action()
else vim.api.nvim_feedkeys(char,'m',true) end
end
function M.vsplit() vim.cmd.vsplit() M.open() end
function M.split() vim.cmd.split() M.open() end
return M