Skip to content

Commit

Permalink
small updates + nicer documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcWeber committed Apr 24, 2012
1 parent 1a07c70 commit 0ca834e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
13 changes: 13 additions & 0 deletions autoload/actions_more.vim
Expand Up @@ -71,3 +71,16 @@ fun! actions_more#RunPHPRHS(background)
\ : ['exec "set efm='.ef.'" ',"set makeprg=python", "make ".join(args, ' ') ]
" think about proper quoting in : case
endf


fun! actions_more#RunRUBYRHS(background)
" errorformat taken from http://www.vim.org/scripts/script.php?script_id=477
let ef= '%f:%l:%m'

let args = ["ruby"] + [ expand('%')]
let args = eval(input('command args: ', string(args)))
return a:background
\ ? "call bg#RunQF(".string(args).", 'c', ".string(ef).")"
\ : ['exec "set efm='.ef.'" ',"set makeprg=python", "make ".join(args, ' ') ]
" think about proper quoting in : case
endf
33 changes: 26 additions & 7 deletions doc/vim-addon-actions.txt
@@ -1,6 +1,32 @@
*actions* this addon provides a list of actions which can be mapped to keys
Author: Marc Weber, marco-oweber@gmx.de


-----------------------------------------------------------------------
HOWTO for end users / CUSTOMIZATION~

There are pairs of key combinations:
- a combination setting an action to the second key combination
- the second key combination running the action.

The default combinations are <s-F2> assigning an action to <F2> etc, see
plugin/actions.vim.

You can override the default mappings. This example will let you use \a to
assign a mapping to <c-a>: >
let g:vim_actions = {}
let g:vim_actions['bindable_keys'] = [ ['\a', '<c-a>'] ]

< Assigning an action means choosing an action from the lits of available
actions. You do so by typing some chars, then using up/down keys and finally
pressing <cr>
Additional plugins can register additional actions.
I use it for compiling code or running interpreters only.

The special command >
ActionOnWriteBuffer
< is special: it always runs the action whenever you write any buffger.

-----------------------------------------------------------------------
HOWTO~

Expand Down Expand Up @@ -52,13 +78,6 @@ many of my plugins:
vim-haxe
...

-----------------------------------------------------------------------
CUSTOMIZATION~

You can override the default mappings. This example will let you use \a to
assign a mapping to <c-a>: >
let g:vim_actions = {}
let g:vim_actions['bindable_keys'] = [ ['\a', '<c-a>'] ]
<


Expand Down
6 changes: 5 additions & 1 deletion plugin/actions.vim
Expand Up @@ -20,17 +20,21 @@ call actions#AddAction('run make', {'action': funcref#Function('actions#CompileR
" perl: not using all of $VIMRUNTIME/compiler/perl.vim because if you dont'
" flush valuable stdout output could be lost cause errors appear before stdout
" dump and the compiler error format drops those lines
call actions#AddAction('perl current file', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [['set efm=\%m\ at\ %f\ line\ %l.'], ["perl", funcref#Function('return expand("%")')]]})})
call actions#AddAction('perl current file', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [['set efm=\%m\ at\ %f\ line\ %l.,\%m\ at\ %f\ line\ %l\,\ at\ end\ of\ line,%m\ at\ %f\ line\ %l\,\ near'], ["perl", funcref#Function('return expand("%")')]]})})
call actions#AddAction('gcc -gdbb current file', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [[], ["gcc", '-o', funcref#Function('return expand("%:r:t")'), '-ggdb', '-O0', funcref#Function('return expand("%")')]]})})
call actions#AddAction('g++ -gdbb current file', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [[], ["g++", '-o', funcref#Function('return expand("%:r:t")'), '-ggdb', '-O0', funcref#Function('return expand("%")')]]})})
call actions#AddAction('shebang (run this script)', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [[], [funcref#Function('return expand("%:p")')]]})})


call actions#AddAction('run ruby background', {'action': funcref#Function('actions_more#RunRUBYRHS', {'args': [1]})})

call actions#AddAction('run php background', {'action': funcref#Function('actions_more#RunPHPRHS', {'args': [1]})})
call actions#AddAction('run python background', {'action': funcref#Function('actions_more#RunPythonRHS', {'args': [1]})})
call actions#AddAction('run python using make', {'action': funcref#Function('actions_more#RunPythonRHS', {'args': [0]})})


call actions#AddAction('sass', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [[], ["sass", funcref#Function('return expand("%")'), funcref#Function('return expand("%:r:t").".css"')]]})})
call actions#AddAction('haml', {'action': funcref#Function('actions#CompileRHSSimple', {'args': [['set efm=Syntax\ error\ on\ line\ %l:%m,Haml\ error\ on\ line\ %l:%m'], ["haml", funcref#Function('return expand("%")'), funcref#Function('return expand("%:r:t").".html"')]]})})

" scala see addon vim-addon-scala
" haxe see addon vim-haxe
Expand Down

0 comments on commit 0ca834e

Please sign in to comment.