add nvim-tree specific menu
This commit is contained in:
parent
8c7d499270
commit
c4547c7dec
|
@ -85,6 +85,117 @@ function get_default_menu()
|
||||||
return menu
|
return menu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function get_nvim_tree_menu()
|
||||||
|
local nvim_tree = require 'nvim-tree.api'
|
||||||
|
local current_node = nvim_tree.tree.get_node_under_cursor
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
name = ' New file',
|
||||||
|
hl = 'ExBlue',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.create(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'a',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' New folder',
|
||||||
|
hl = 'ExBlue',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.create(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'a',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Open',
|
||||||
|
hl = 'ExGreen',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.node.open.edit(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'o',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Open in vertical split',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.node.open.vertical(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = '<C-v>',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Open in horizontal split',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.node.open.horizontal(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = '<C-x>',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Cut',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.cut(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'x',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Copy',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.copy.node(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'c',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Paste',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.paste(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'p',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'Copy absolute path',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.copy.absolute_path(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'gy',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'Copy relative path',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.copy.relative_path(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'Y',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'Copy filename',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.copy.filename(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'y',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Rename',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.rename(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'r',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = ' Delete',
|
||||||
|
hl = 'ExRed',
|
||||||
|
cmd = function()
|
||||||
|
nvim_tree.fs.remove(current_node())
|
||||||
|
end,
|
||||||
|
rtxt = 'd',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function get_lsp_menu()
|
function get_lsp_menu()
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
|
@ -362,7 +473,13 @@ return {
|
||||||
vim.keymap.set('n', '<RightMouse>', function()
|
vim.keymap.set('n', '<RightMouse>', function()
|
||||||
if not helper.contains(ignore_ft, vim.bo.ft) then
|
if not helper.contains(ignore_ft, vim.bo.ft) then
|
||||||
vim.cmd.exec '"normal! \\<RightMouse>"'
|
vim.cmd.exec '"normal! \\<RightMouse>"'
|
||||||
require('menu').open(get_default_menu 'n', { mouse = true })
|
local menu
|
||||||
|
if vim.bo.ft == 'NvimTree' then
|
||||||
|
menu = get_nvim_tree_menu()
|
||||||
|
else
|
||||||
|
menu = get_default_menu()
|
||||||
|
end
|
||||||
|
require('menu').open(menu, { mouse = true })
|
||||||
end
|
end
|
||||||
end, {})
|
end, {})
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in a new issue