]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/nerdtree_plugin/exec_menuitem.vim
Add vim again :)
[rbdr/dotfiles] / vim / nerdtree_plugin / exec_menuitem.vim
1 " ============================================================================
2 " File: exec_menuitem.vim
3 " Description: plugin for NERD Tree that provides an execute file menu item
4 " Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
5 " Last Change: 22 July, 2009
6 " License: This program is free software. It comes without any warranty,
7 " to the extent permitted by applicable law. You can redistribute
8 " it and/or modify it under the terms of the Do What The Fuck You
9 " Want To Public License, Version 2, as published by Sam Hocevar.
10 " See http://sam.zoy.org/wtfpl/COPYING for more details.
11 "
12 " ============================================================================
13 if exists("g:loaded_nerdtree_exec_menuitem")
14 finish
15 endif
16 let g:loaded_nerdtree_exec_menuitem = 1
17
18 call NERDTreeAddMenuItem({
19 \ 'text': '(!)Execute file',
20 \ 'shortcut': '!',
21 \ 'callback': 'NERDTreeExecFile',
22 \ 'isActiveCallback': 'NERDTreeExecFileActive' })
23
24 function! NERDTreeExecFileActive()
25 let node = g:NERDTreeFileNode.GetSelected()
26 return !node.path.isDirectory && node.path.isExecutable
27 endfunction
28
29 function! NERDTreeExecFile()
30 let treenode = g:NERDTreeFileNode.GetSelected()
31 echo "==========================================================\n"
32 echo "Complete the command to execute (add arguments etc):\n"
33 let cmd = treenode.path.str({'escape': 1})
34 let cmd = input(':!', cmd . ' ')
35
36 if cmd != ''
37 exec ':!' . cmd
38 else
39 echo "Aborted"
40 endif
41 endfunction