Add a "copy path to clipboard" menu option (#1002)

* Add menu item to copy the node's path to the clipboard.

It works on Mac. Check Windows later.

* Handle case where clipboard is not a compiled feature of Vim.

* Change menu text if clipboard is unavailable.
This commit is contained in:
Phil Runninger 2019-06-13 09:17:19 -04:00 committed by GitHub
parent 70dc34cb69
commit 12dea6ccb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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': (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'})
@ -364,6 +365,17 @@ function! NERDTreeCopyNode()
redraw!
endfunction
" FUNCTION: NERDTreeCopyPath() {{{1
function! NERDTreeCopyPath()
let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
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
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()