nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 727770147a7589ab3a06722f4852c0237c8b3549
parent a0e49c9b117d68dbc3e308b79529f8a3ab18e0f8
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Tue, 10 Apr 2018 08:23:02 -0400

Merge pull request #824 from ngnmhieu/master

Support revealing file and executing file with xdg-open for Linux
Diffstat:
Mnerdtree_plugin/fs_menu.vim | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim
@@ -29,6 +29,11 @@ if has("gui_mac") || has("gui_macvim") || has("mac")
     call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
 endif
 
+if executable("xdg-open")
+    call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'})
+    call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'})
+endif
+
 if g:NERDTreePath.CopyingSupported()
     call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
 endif
@@ -337,4 +342,22 @@ function! NERDTreeExecuteFile()
     endif
 endfunction
 
+" FUNCTION: NERDTreeRevealFileLinux() {{{1
+function! NERDTreeRevealFileLinux()
+    let treenode = g:NERDTreeFileNode.GetSelected()
+    let parentnode = treenode.parent
+    if parentnode != {}
+        call system("xdg-open '" . parentnode.path.str() . "' &")
+    endif
+endfunction
+
+" FUNCTION: NERDTreeExecuteFileLinux() {{{1
+function! NERDTreeExecuteFileLinux()
+    let treenode = g:NERDTreeFileNode.GetSelected()
+    if treenode != {}
+        call system("xdg-open '" . treenode.path.str() . "' &")
+    endif
+endfunction
+
 " vim: set sw=4 sts=4 et fdm=marker:
+