add preview
This commit is contained in:
21
README.md
21
README.md
@@ -47,12 +47,8 @@ let g:lua_tree_bindings = {
|
|||||||
\ 'edit_vsplit': '<C-v>',
|
\ 'edit_vsplit': '<C-v>',
|
||||||
\ 'edit_split': '<C-x>',
|
\ 'edit_split': '<C-x>',
|
||||||
\ 'edit_tab': '<C-t>',
|
\ 'edit_tab': '<C-t>',
|
||||||
\ 'cd': '.',
|
\ 'preview': '<Tab>',
|
||||||
\ 'create': 'a',
|
\ 'cd': '<C-]>',
|
||||||
\ 'remove': 'd',
|
|
||||||
\ 'rename': 'r'
|
|
||||||
\ }
|
|
||||||
|
|
||||||
" default will show icon by default if no icon is provided
|
" default will show icon by default if no icon is provided
|
||||||
" default shows no icon by default
|
" default shows no icon by default
|
||||||
let g:lua_tree_icons = {
|
let g:lua_tree_icons = {
|
||||||
@@ -85,19 +81,20 @@ highlight LuaTreeFolderIcon guibg=blue
|
|||||||
|
|
||||||
- move around like in any vim buffer
|
- move around like in any vim buffer
|
||||||
- `<CR>` on `..` will cd in the above directory
|
- `<CR>` on `..` will cd in the above directory
|
||||||
- `.` will cd in the directory under the cursor
|
- `<C-]>` will cd in the directory under the cursor
|
||||||
- type `a` to add a file. Adding a directory requires leaving a leading `/` at the end of the path.
|
- type `a` to add a file. Adding a directory requires leaving a leading `/` at the end of the path.
|
||||||
> you can add multiple directories by doing foo/bar/baz/f and it will add foo bar and baz directories and f as a file
|
> you can add multiple directories by doing foo/bar/baz/f and it will add foo bar and baz directories and f as a file
|
||||||
- type `r` to rename a file
|
- type `r` to rename a file
|
||||||
- type `d` to delete a file (will prompt for confirmation)
|
- type `d` to delete a file (will prompt for confirmation)
|
||||||
- if the file is a directory, `<CR>` will open the directory otherwise it will open the file in the buffer near the tree
|
- if the file is a directory, `<CR>` will open the directory otherwise it will open the file in the buffer near the tree
|
||||||
- if the file is a symlink, `<CR>` will follow the symlink (if the target is a file)
|
- if the file is a symlink, `<CR>` will follow the symlink (if the target is a file)
|
||||||
- type `<C-v>` will open the file in a vertical split
|
- `<C-v>` will open the file in a vertical split
|
||||||
- type `<C-x>` will open the file in a horizontal split
|
- `<C-x>` will open the file in a horizontal split
|
||||||
- type `<C-t>` will open the file in a new tab
|
- `<C-t>` will open the file in a new tab
|
||||||
- type `gx` to open the file with the `open` command on MACOS and `xdg-open` in linux
|
- `<Tab>` will open the file as a preview (keeps the cursor in the tree)
|
||||||
|
- `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux
|
||||||
- Double left click acts like `<CR>`
|
- Double left click acts like `<CR>`
|
||||||
- Double right click acts like `.`
|
- Double right click acts like `<C-]>`
|
||||||
|
|
||||||
## Note
|
## Note
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ INFORMATIONS *nvim-tree-info*
|
|||||||
|
|
||||||
- move around like in any vim buffer
|
- move around like in any vim buffer
|
||||||
- '<CR>' on '..' will cd in the above directory
|
- '<CR>' on '..' will cd in the above directory
|
||||||
- typing '.' will cd in the directory under the cursor
|
- typing '<C-]>' will cd in the directory under the cursor
|
||||||
|
|
||||||
- type 'a' to add a file
|
- type 'a' to add a file
|
||||||
- type 'r' to rename a file
|
- type 'r' to rename a file
|
||||||
@@ -131,14 +131,15 @@ INFORMATIONS *nvim-tree-info*
|
|||||||
- if the file is a directory, '<CR>' will open the directory
|
- if the file is a directory, '<CR>' will open the directory
|
||||||
- otherwise it will open the file in the buffer near the tree
|
- otherwise it will open the file in the buffer near the tree
|
||||||
- if the file is a symlink, '<CR>' will follow the symlink
|
- if the file is a symlink, '<CR>' will follow the symlink
|
||||||
- type '<C-v>' will open the file in a vertical split
|
- '<C-v>' will open the file in a vertical split
|
||||||
- type '<C-x>' will open the file in a horizontal split
|
- '<C-x>' will open the file in a horizontal split
|
||||||
- type '<C-t>' will open the file in a new tab
|
- '<C-t>' will open the file in a new tab
|
||||||
- type 'gx' to open the file with the `open` command on macos and `xdg-open`
|
- '<Tab>' will open the file as a preview (keeps the cursor in the tree)
|
||||||
|
- 'gx' opens the file with the `open` command on macos and `xdg-open`
|
||||||
on linux.
|
on linux.
|
||||||
|
|
||||||
- Double left click acts like '<CR>'
|
- Double left click acts like '<CR>'
|
||||||
- Double right click acts like '.'
|
- Double right click acts like '<C-]>'
|
||||||
|
|
||||||
|g:lua_tree_bindings| *g:lua_tree_bindings*
|
|g:lua_tree_bindings| *g:lua_tree_bindings*
|
||||||
|
|
||||||
@@ -150,7 +151,8 @@ default keybindings will be applied to undefined keys.
|
|||||||
\ edit_vsplit: '<c-v>',
|
\ edit_vsplit: '<c-v>',
|
||||||
\ edit_split: '<c-x>',
|
\ edit_split: '<c-x>',
|
||||||
\ edit_tab: '<c-t>',
|
\ edit_tab: '<c-t>',
|
||||||
\ cd: '.',
|
\ cd: '<c-]>',
|
||||||
|
\ preview: '<Tab>',
|
||||||
\ create: 'a',
|
\ create: 'a',
|
||||||
\ remove: 'd',
|
\ remove: 'd',
|
||||||
\ rename: 'r'
|
\ rename: 'r'
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ function M.get_bindings()
|
|||||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||||
edit_split = keybindings.edit_split or '<C-x>',
|
edit_split = keybindings.edit_split or '<C-x>',
|
||||||
edit_tab = keybindings.edit_tab or '<C-t>',
|
edit_tab = keybindings.edit_tab or '<C-t>',
|
||||||
|
preview = keybindings.preview or '<Tab>',
|
||||||
cd = keybindings.cd or '<C-]>',
|
cd = keybindings.cd or '<C-]>',
|
||||||
create = keybindings.create or 'a',
|
create = keybindings.create or 'a',
|
||||||
remove = keybindings.remove or 'd',
|
remove = keybindings.remove or 'd',
|
||||||
|
|||||||
@@ -183,7 +183,16 @@ function M.open_file(mode, filename)
|
|||||||
else
|
else
|
||||||
api.nvim_command('noautocmd wincmd l')
|
api.nvim_command('noautocmd wincmd l')
|
||||||
end
|
end
|
||||||
api.nvim_command(string.format("%s %s", mode, filename))
|
if mode == 'preview' then
|
||||||
|
api.nvim_command(string.format("edit %s", filename))
|
||||||
|
if vim.g.lua_tree_side == 'right' then
|
||||||
|
api.nvim_command('noautocmd wincmd l')
|
||||||
|
else
|
||||||
|
api.nvim_command('noautocmd wincmd h')
|
||||||
|
end
|
||||||
|
else
|
||||||
|
api.nvim_command(string.format("%s %s", mode, filename))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.change_dir(foldername)
|
function M.change_dir(foldername)
|
||||||
@@ -207,6 +216,7 @@ local function set_mappings()
|
|||||||
[bindings.create] = 'on_keypress("create")';
|
[bindings.create] = 'on_keypress("create")';
|
||||||
[bindings.remove] = 'on_keypress("remove")';
|
[bindings.remove] = 'on_keypress("remove")';
|
||||||
[bindings.rename] = 'on_keypress("rename")';
|
[bindings.rename] = 'on_keypress("rename")';
|
||||||
|
[bindings.preview] = 'on_keypress("preview")';
|
||||||
gx = "xdg_open()";
|
gx = "xdg_open()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ function M.on_keypress(mode)
|
|||||||
return fs.rename(node)
|
return fs.rename(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if mode == 'preview' then
|
||||||
|
if node.entries ~= nil or node.name == '..' then return end
|
||||||
|
return tree.open_file(mode, node.absolute_path)
|
||||||
|
end
|
||||||
|
|
||||||
if node.name == ".." then
|
if node.name == ".." then
|
||||||
return tree.change_dir("..")
|
return tree.change_dir("..")
|
||||||
elseif mode == "cd" and node.entries ~= nil then
|
elseif mode == "cd" and node.entries ~= nil then
|
||||||
@@ -49,6 +54,7 @@ function M.on_keypress(mode)
|
|||||||
|
|
||||||
if node.link_to then
|
if node.link_to then
|
||||||
local stat = luv.fs_stat(node.link_to)
|
local stat = luv.fs_stat(node.link_to)
|
||||||
|
-- TODO: potentially CD here
|
||||||
if stat.type == 'directory' then return end
|
if stat.type == 'directory' then return end
|
||||||
tree.open_file(mode, node.link_to)
|
tree.open_file(mode, node.link_to)
|
||||||
elseif node.entries ~= nil then
|
elseif node.entries ~= nil then
|
||||||
|
|||||||
Reference in New Issue
Block a user