A tree explorer plugin for vim.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.6 KiB

  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. call NERDTreeAddMenuItem({
  18. \ 'text': '(!)Execute file',
  19. \ 'shortcut': '!',
  20. \ 'callback': 'NERDTreeExecFile',
  21. \ 'isActiveCallback': 'NERDTreeExecFileActive' })
  22. function! NERDTreeExecFileActive()
  23. let node = g:NERDTreeFileNode.GetSelected()
  24. return !node.path.isDirectory && node.path.isExecutable
  25. endfunction
  26. function! NERDTreeExecFile()
  27. let treenode = g:NERDTreeFileNode.GetSelected()
  28. echo "==========================================================\n"
  29. echo "Complete the command to execute (add arguments etc):\n"
  30. let cmd = treenode.path.str({'escape': 1})
  31. let cmd = input(':!', cmd . ' ')
  32. if cmd != ''
  33. exec ':!' . cmd
  34. else
  35. echo "Aborted"
  36. endif
  37. endfunction