-USING: editors.vim kernel namespaces ;
+USING: editors.vim environment fry io.files io.pathnames kernel
+namespaces sequences splitting ;
IN: editors.macvim
SINGLETON: macvim
macvim \ vim-editor set-global
-M: macvim vim-path \ vim-path get-global "mvim" or ;
+: find-binary-path ( string -- path/f )
+ [ "PATH" os-env ":" split ] dip '[ _ append-path exists? ] find nip ;
+
+M: macvim find-vim-path "mvim" find-binary-path { "open" "-a" "MacVim" } or ;
M: macvim vim-detached? t ;
+M: macvim vim-open-line? f ;
HOOK: find-vim-path vim-editor ( -- path )
HOOK: vim-detached? vim-editor ( -- detached? )
+HOOK: vim-open-line? vim-editor ( -- ? )
+M: object vim-open-line? t ;
M: vim find-vim-path "vim" ;
M: vim vim-detached? f ;
: vim-command ( file line -- command )
[
actual-vim-path dup string? [ , ] [ % ] if
- [ , ] [ number>string "+" prepend , ] bi*
+ [ , ] [ vim-open-line? [ number>string "+" prepend , ] [ drop ] if ] bi*
] { } make ;
: vim ( file line -- )