From 0774944b8d4a953109c74bd244dc9ddd5042af59 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 30 Oct 2011 16:10:27 -0700 Subject: [PATCH] Find the macvim bundle or use mvim. Add a flag for -g option to vim. --- basis/editors/gvim/gvim.factor | 3 ++- basis/editors/macvim/macvim.factor | 18 ++++++++++++------ basis/editors/vim/vim.factor | 8 ++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/basis/editors/gvim/gvim.factor b/basis/editors/gvim/gvim.factor index 2c911c3381..b0d3399f23 100644 --- a/basis/editors/gvim/gvim.factor +++ b/basis/editors/gvim/gvim.factor @@ -13,5 +13,6 @@ M: object find-gvim-path f ; M: gvim find-vim-path find-gvim-path "gvim" or ; M: gvim vim-detached? t ; +M: gvim vim-ui? t ; -os windows? [ "editors.gvim.windows" require ] when \ No newline at end of file +os windows? [ "editors.gvim.windows" require ] when diff --git a/basis/editors/macvim/macvim.factor b/basis/editors/macvim/macvim.factor index 46f346828e..72a89a0efc 100644 --- a/basis/editors/macvim/macvim.factor +++ b/basis/editors/macvim/macvim.factor @@ -1,13 +1,19 @@ -USING: editors.vim environment fry io.files io.pathnames kernel -namespaces sequences splitting ; +USING: core-foundation.launch-services editors.vim io.pathnames +io.standard-paths kernel namespaces ; IN: editors.macvim SINGLETON: macvim macvim \ vim-editor set-global -: find-binary-path ( string -- path/f ) - [ "PATH" os-env ":" split ] dip '[ _ append-path exists? ] find nip ; +: find-macvim-bundle-path ( -- path/f ) + "org.vim.MacVim" find-native-bundle [ + "Contents/MacOS/Vim" append-path + ] [ + f + ] if* ; + +M: macvim find-vim-path + find-macvim-bundle-path "mvim" or ; -M: macvim find-vim-path "mvim" find-binary-path { "open" "-a" "MacVim" } or ; M: macvim vim-detached? t ; -M: macvim vim-open-line? f ; +M: macvim vim-ui? t ; diff --git a/basis/editors/vim/vim.factor b/basis/editors/vim/vim.factor index 855e2ad158..03e8435015 100644 --- a/basis/editors/vim/vim.factor +++ b/basis/editors/vim/vim.factor @@ -11,12 +11,11 @@ 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 ; +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* ; @@ -24,7 +23,8 @@ M: vim vim-detached? f ; : vim-command ( file line -- command ) [ actual-vim-path dup string? [ , ] [ % ] if - [ , ] [ vim-open-line? [ number>string "+" prepend , ] [ drop ] if ] bi* + vim-ui? [ "-g" , ] when + [ , ] [ number>string "+" prepend , ] bi* ] { } make ; : vim ( file line -- )