2011-10-29 18:10:42 -04:00
|
|
|
USING: editors io.backend io.launcher kernel make math.parser
|
|
|
|
namespaces sequences strings system vocabs.loader ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: editors.vim
|
|
|
|
|
|
|
|
SYMBOL: vim-editor
|
|
|
|
|
2008-06-14 05:11:30 -04:00
|
|
|
SINGLETON: vim
|
2011-10-29 18:10:42 -04:00
|
|
|
\ vim vim-editor set-global
|
|
|
|
|
|
|
|
SYMBOL: vim-path
|
|
|
|
|
|
|
|
HOOK: find-vim-path vim-editor ( -- path )
|
|
|
|
HOOK: vim-detached? vim-editor ( -- detached? )
|
2011-10-30 19:10:27 -04:00
|
|
|
HOOK: vim-ui? vim-editor ( -- ui? )
|
2011-10-29 18:10:42 -04:00
|
|
|
|
|
|
|
M: vim find-vim-path "vim" ;
|
|
|
|
M: vim vim-detached? f ;
|
2011-10-30 19:10:27 -04:00
|
|
|
M: vim vim-ui? f ;
|
2011-10-29 18:10:42 -04:00
|
|
|
|
|
|
|
: actual-vim-path ( -- path )
|
|
|
|
\ vim-path get-global [ find-vim-path ] unless* ;
|
|
|
|
|
|
|
|
: vim-command ( file line -- command )
|
2008-01-24 02:50:40 -05:00
|
|
|
[
|
2011-10-29 18:10:42 -04:00
|
|
|
actual-vim-path dup string? [ , ] [ % ] if
|
2011-10-30 19:10:27 -04:00
|
|
|
vim-ui? [ "-g" , ] when
|
|
|
|
[ , ] [ number>string "+" prepend , ] bi*
|
2008-01-24 02:50:40 -05:00
|
|
|
] { } make ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-05-15 17:06:48 -04:00
|
|
|
: vim ( file line -- )
|
2011-10-29 18:10:42 -04:00
|
|
|
vim-command vim-detached? [ run-detached ] [ run-process ] if drop ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-05-15 17:06:48 -04:00
|
|
|
[ vim ] edit-hook set-global
|