]> gitweb.factorcode.org Git - factor.git/commitdiff
Look for mvim on mac and use 'open -a MacVim' if it's not in the path. Since 'open...
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 29 Oct 2011 22:27:08 +0000 (15:27 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 29 Oct 2011 22:31:06 +0000 (15:31 -0700)
basis/editors/macvim/macvim.factor
basis/editors/vim/vim.factor

index f67bf141a71991b58e3c7f376e0135a7640c7b72..46f346828e68102db50cbfa7706194fe02e34ecc 100644 (file)
@@ -1,8 +1,13 @@
-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 ;
index 33e596e1ad33cfb0a22377f4861e5459f47a4fef..855e2ad1586101da3fc988a961c05d00f3c6f4c1 100644 (file)
@@ -11,7 +11,9 @@ SYMBOL: vim-path
 
 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 ;
@@ -22,7 +24,7 @@ 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 -- )