Feature: add option for user keybindings
This commit is contained in:
parent
c003626dee
commit
ff860ecb49
14
README.md
14
README.md
@ -31,6 +31,20 @@ let g:lua_tree_show_icons = {
|
|||||||
"1 by default, notice that if 'files' is 1, it will only display
|
"1 by default, notice that if 'files' is 1, it will only display
|
||||||
"if web-devicons is installed and on your runtimepath
|
"if web-devicons is installed and on your runtimepath
|
||||||
|
|
||||||
|
" You can edit keybindings be defining this variable
|
||||||
|
" You don't have to define all keys.
|
||||||
|
" NOTE: the 'edit' key will wrap/unwrap a folder and open a file
|
||||||
|
let g:lua_tree_bindings = {
|
||||||
|
\ 'edit': '<CR>',
|
||||||
|
\ 'edit_vsplit': '<C-v>',
|
||||||
|
\ 'edit_split': '<C-x>',
|
||||||
|
\ 'edit_tab': '<C-t>',
|
||||||
|
\ 'cd': '.',
|
||||||
|
\ 'create': 'a',
|
||||||
|
\ 'remove': 'd',
|
||||||
|
\ 'rename': 'r'
|
||||||
|
\ }
|
||||||
|
|
||||||
nnoremap <C-n> :LuaTreeToggle<CR>
|
nnoremap <C-n> :LuaTreeToggle<CR>
|
||||||
nnoremap <leader>r :LuaTreeRefresh<CR>
|
nnoremap <leader>r :LuaTreeRefresh<CR>
|
||||||
nnoremap <leader>n :LuaTreeFindFile<CR>
|
nnoremap <leader>n :LuaTreeFindFile<CR>
|
||||||
|
|||||||
@ -109,6 +109,22 @@ INFORMATIONS *nvim-tree-info*
|
|||||||
- Double left click acts like '<CR>'
|
- Double left click acts like '<CR>'
|
||||||
- Double right click acts like '.'
|
- Double right click acts like '.'
|
||||||
|
|
||||||
|
|g:lua_tree_bindings| *g:lua_tree_bindings*
|
||||||
|
|
||||||
|
you can change default keybindings by defining this variable.
|
||||||
|
default keybindings will be applied to undefined keys.
|
||||||
|
>
|
||||||
|
let g:lua_tree_bindings = {
|
||||||
|
\ edit: '<cr>',
|
||||||
|
\ edit_vsplit: '<c-v>',
|
||||||
|
\ edit_split: '<c-x>',
|
||||||
|
\ edit_tab: '<c-t>',
|
||||||
|
\ cd: '.',
|
||||||
|
\ create: 'a',
|
||||||
|
\ remove: 'd',
|
||||||
|
\ rename: 'r'
|
||||||
|
\ }
|
||||||
|
|
||||||
|Features| *nvim-tree-features*
|
|Features| *nvim-tree-features*
|
||||||
|
|
||||||
File icons with vim-devicons.
|
File icons with vim-devicons.
|
||||||
|
|||||||
1
doc/tags
1
doc/tags
@ -3,6 +3,7 @@
|
|||||||
:LuaTreeToggle nvim-tree-lua.txt /*:LuaTreeToggle*
|
:LuaTreeToggle nvim-tree-lua.txt /*:LuaTreeToggle*
|
||||||
g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close*
|
g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close*
|
||||||
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
|
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
|
||||||
|
g:lua_tree_bindings nvim-tree-lua.txt /*g:lua_tree_bindings*
|
||||||
g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow*
|
g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow*
|
||||||
g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
|
g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
|
||||||
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
|
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
|
||||||
|
|||||||
@ -27,10 +27,24 @@ local colors = {
|
|||||||
dark_red = get('terminal_color_9', 'DarkRed'),
|
dark_red = get('terminal_color_9', 'DarkRed'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local keybindings = get('lua_tree_bindings', {});
|
||||||
|
|
||||||
|
local bindings = {
|
||||||
|
edit = keybindings.edit or '<CR>',
|
||||||
|
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||||
|
edit_split = keybindings.edit_split or '<C-x>',
|
||||||
|
edit_tab = keybindings.edit_tab or '<C-t>',
|
||||||
|
cd = keybindings.cd or '.',
|
||||||
|
create = keybindings.create or 'a',
|
||||||
|
remove = keybindings.remove or 'd',
|
||||||
|
rename = keybindings.remove or 'r',
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
SHOW_FOLDER_ICON = SHOW_FOLDER_ICON,
|
SHOW_FOLDER_ICON = SHOW_FOLDER_ICON,
|
||||||
SHOW_FILE_ICON = SHOW_FILE_ICON,
|
SHOW_FILE_ICON = SHOW_FILE_ICON,
|
||||||
SHOW_GIT_ICON = SHOW_GIT_ICON,
|
SHOW_GIT_ICON = SHOW_GIT_ICON,
|
||||||
colors = colors
|
colors = colors,
|
||||||
|
bindings = bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,8 @@ local highlight = libformat.highlight_buffer
|
|||||||
local stateutils = require 'lib/state'
|
local stateutils = require 'lib/state'
|
||||||
local get_tree = stateutils.get_tree
|
local get_tree = stateutils.get_tree
|
||||||
|
|
||||||
|
local bindings = require 'lib/config'.bindings
|
||||||
|
|
||||||
local function get_buf()
|
local function get_buf()
|
||||||
local regex = '.*'..BUF_NAME..'$';
|
local regex = '.*'..BUF_NAME..'$';
|
||||||
|
|
||||||
@ -132,16 +134,16 @@ local function set_mappings()
|
|||||||
if not buf then return end
|
if not buf then return end
|
||||||
|
|
||||||
local mappings = {
|
local mappings = {
|
||||||
['<CR>'] = 'open_file("edit")';
|
|
||||||
['<2-LeftMouse>'] = 'open_file("edit")';
|
['<2-LeftMouse>'] = 'open_file("edit")';
|
||||||
['<2-RightMouse>'] = 'open_file("chdir")';
|
['<2-RightMouse>'] = 'open_file("chdir")';
|
||||||
['<C-v>'] = 'open_file("vsplit")';
|
[bindings.edit] = 'open_file("edit")';
|
||||||
['<C-x>'] = 'open_file("split")';
|
[bindings.edit_vsplit] = 'open_file("vsplit")';
|
||||||
['<C-t>'] = 'open_file("tabnew")';
|
[bindings.edit_split] = 'open_file("split")';
|
||||||
['.'] = 'open_file("chdir")';
|
[bindings.edit_tab] = 'open_file("tabnew")';
|
||||||
a = 'edit_file("create")';
|
[bindings.cd] = 'open_file("chdir")';
|
||||||
d = 'edit_file("remove")';
|
[bindings.create] = 'edit_file("create")';
|
||||||
r = 'edit_file("rename")';
|
[bindings.remove] = 'edit_file("remove")';
|
||||||
|
[bindings.rename] = 'edit_file("rename")';
|
||||||
}
|
}
|
||||||
|
|
||||||
for k,v in pairs(mappings) do
|
for k,v in pairs(mappings) do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user