From c905a5d7b87051e574c2e72fae57e56c456ba2f4 Mon Sep 17 00:00:00 2001 From: Arvid Gerstmann Date: Thu, 29 Nov 2018 15:17:39 +0100 Subject: [PATCH] Allow modification of menu keybindings (#923) --- doc/NERDTree.txt | 16 ++++++++++++++++ lib/nerdtree/menu_controller.vim | 6 +++--- plugin/NERD_tree.vim | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 42c31cc..562d9d5 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -605,6 +605,22 @@ menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| +------------------------------------------------------------------------------ + *NERDTreeMenu-j* +Default key: j +Map option: NERDTreeMenuDown +Applies to: The NERD tree menu. + +Moves the cursor down. + +------------------------------------------------------------------------------ + *NERDTreeMenu-k* +Default key: k +Map option: NERDTreeMenuUp +Applies to: The NERD tree menu. + +Moves the cursor up. + ============================================================================== 3. Customisation *NERDTreeOptions* diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 68e4d30..84bdb26 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -49,7 +49,7 @@ endfunction "FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() - echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" + echo "NERDTree Menu. Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter and the shortcuts indicated" echo "==========================================================" for i in range(0, len(self.menuItems)-1) @@ -71,9 +71,9 @@ endfunction "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) - if a:key == 'j' + if a:key == g:NERDTreeMenuDown call self._cursorDown() - elseif a:key == 'k' + elseif a:key == g:NERDTreeMenuUp call self._cursorUp() elseif a:key == nr2char(27) "escape let self.selection = -1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 62506e5..57a65a1 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,6 +148,8 @@ call s:initVariable("g:NERDTreeMapToggleZoom", "A") call s:initVariable("g:NERDTreeMapUpdir", "u") call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") call s:initVariable("g:NERDTreeMapCWD", "CD") +call s:initVariable("g:NERDTreeMenuDown", "j") +call s:initVariable("g:NERDTreeMenuUp", "k") "SECTION: Load class files{{{2 call nerdtree#loadClassFiles()