From 03b669aeca91bdf42bd44cbe6ac33e7f46567ded Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 23 May 2019 08:52:16 -0400 Subject: [PATCH 1/3] Add menu item to copy the node's path to the clipboard. It works on Mac. Check Windows later. --- nerdtree_plugin/fs_menu.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 3eef5176..d32a5709 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -37,6 +37,7 @@ endif if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif +call NERDTreeAddMenuItem({'text': 'copy (p)ath to clipboard', 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) if has("unix") || has("osx") call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) @@ -364,6 +365,13 @@ function! NERDTreeCopyNode() redraw! endfunction +" FUNCTION: NERDTreeCopyPath() {{{1 +function! NERDTreeCopyPath() + let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() + let @+ = l:nodePath + call nerdtree#echo("The path (" . l:nodePath . ") was copied to your clipboard.") +endfunction + " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() From b8b6c53416549f655847b396bd18f4f4d592540d Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 12 Jun 2019 09:20:53 -0400 Subject: [PATCH 2/3] Handle case where clipboard is not a compiled feature of Vim. --- nerdtree_plugin/fs_menu.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index d32a5709..15cfe56b 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -368,8 +368,12 @@ endfunction " FUNCTION: NERDTreeCopyPath() {{{1 function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() - let @+ = l:nodePath - call nerdtree#echo("The path (" . l:nodePath . ") was copied to your clipboard.") + if has("clipboard") + let @* = l:nodePath + call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") + else + call nerdtree#echo("The full path is: " . l:nodePath) + endif endfunction " FUNCTION: NERDTreeQuickLook() {{{1 From e35c836ca8c5bf61491b5e35b42c4144fc9ebe3b Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 12 Jun 2019 09:28:22 -0400 Subject: [PATCH 3/3] Change menu text if clipboard is unavailable. --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 15cfe56b..5c37e4d0 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -37,7 +37,7 @@ endif if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif -call NERDTreeAddMenuItem({'text': 'copy (p)ath to clipboard', 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) +call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) if has("unix") || has("osx") call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})