From 2e9d43b6f83b2d392521397693a940449fa7565c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Altay=C3=B3?= Date: Fri, 22 May 2020 14:57:19 +0200 Subject: [PATCH] cmd.exe /c start "" for windows default viewer support (#1130) * support for default viewer in Windows * updated changelog * Update nerdtree_plugin/fs_menu.vim Co-authored-by: Phil Runninger * Update nerdtree_plugin/fs_menu.vim Co-authored-by: Phil Runninger Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c290f..30f4758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.13**: Invoke-Item for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) - **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. [#1126](https://github.com/preservim/nerdtree/pull/1126) - **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122) - **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9750976..3073414 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -34,6 +34,10 @@ if executable('xdg-open') call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) endif +if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif @@ -451,4 +455,15 @@ function! NERDTreeExecuteFileLinux() call system('xdg-open ' . shellescape(l:node.path.str())) endfunction +" FUNCTION: NERDTreeExecuteFileWindows() {{{1 +function! NERDTreeExecuteFileWindows() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) +endfunction + " vim: set sw=4 sts=4 et fdm=marker: