nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
nerdtree_plugin/exec_menuitem.vim (1586B)
   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 " License:     This program is free software. It comes without any warranty,
   6 "              to the extent permitted by applicable law. You can redistribute
   7 "              it and/or modify it under the terms of the Do What The Fuck You
   8 "              Want To Public License, Version 2, as published by Sam Hocevar.
   9 "              See http://sam.zoy.org/wtfpl/COPYING for more details.
  10 "
  11 " ============================================================================
  12 if exists('g:loaded_nerdtree_exec_menuitem')
  13     finish
  14 endif
  15 let g:loaded_nerdtree_exec_menuitem = 1
  16 
  17 call NERDTreeAddMenuItem({
  18             \ 'text': '(!)Execute file',
  19             \ 'shortcut': '!',
  20             \ 'callback': 'NERDTreeExecFile',
  21             \ 'isActiveCallback': 'NERDTreeExecFileActive' })
  22 
  23 function! NERDTreeExecFileActive()
  24     let node = g:NERDTreeFileNode.GetSelected()
  25     return !node.path.isDirectory && node.path.isExecutable
  26 endfunction
  27 
  28 function! NERDTreeExecFile()
  29     let treenode = g:NERDTreeFileNode.GetSelected()
  30     echo "==========================================================\n"
  31     echo "Complete the command to execute (add arguments etc):\n"
  32     let cmd = treenode.path.str({'escape': 1})
  33     let cmd = input(':!', cmd . ' ')
  34 
  35     if cmd !=# ''
  36         exec ':!' . cmd
  37     else
  38         echo 'Aborted'
  39     endif
  40 endfunction