factor/basis/editors/vim/vim.factor

34 lines
822 B
Factor
Raw Normal View History

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
\ vim vim-editor set-global
SYMBOL: vim-path
HOOK: find-vim-path vim-editor ( -- path )
HOOK: vim-detached? vim-editor ( -- detached? )
HOOK: vim-ui? vim-editor ( -- ui? )
M: vim find-vim-path "vim" ;
M: vim vim-detached? f ;
M: vim vim-ui? f ;
: 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
[
actual-vim-path dup string? [ , ] [ % ] if
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
: vim ( file line -- )
vim-command vim-detached? [ run-detached ] [ run-process ] if drop ;
2007-09-20 18:09:08 -04:00
[ vim ] edit-hook set-global