diff --git a/basis/editors/gvim/gvim.factor b/basis/editors/gvim/gvim.factor index 277cd734cc..2c911c3381 100644 --- a/basis/editors/gvim/gvim.factor +++ b/basis/editors/gvim/gvim.factor @@ -1,24 +1,17 @@ -USING: io.backend io.files kernel math math.parser -namespaces sequences system combinators -editors.vim vocabs.loader make ; +USING: editors.vim io.backend kernel namespaces system +vocabs.loader ; IN: editors.gvim ! This code builds on the code in editors.vim; see there for ! more information. SINGLETON: gvim - -HOOK: gvim-path io-backend ( -- path ) - -M: gvim vim-command ( file line -- string ) - [ - gvim-path , - number>string "+" prepend , , - ] { } make ; - gvim vim-editor set-global -{ - { [ os unix? ] [ "editors.gvim.unix" ] } - { [ os windows? ] [ "editors.gvim.windows" ] } -} cond require +HOOK: find-gvim-path io-backend ( -- path ) +M: object find-gvim-path f ; + +M: gvim find-vim-path find-gvim-path "gvim" or ; +M: gvim vim-detached? t ; + +os windows? [ "editors.gvim.windows" require ] when \ No newline at end of file diff --git a/basis/editors/gvim/unix/authors.txt b/basis/editors/gvim/unix/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/basis/editors/gvim/unix/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/basis/editors/gvim/unix/tags.txt b/basis/editors/gvim/unix/tags.txt deleted file mode 100644 index ebb74b4d5f..0000000000 --- a/basis/editors/gvim/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -not loaded diff --git a/basis/editors/gvim/unix/unix.factor b/basis/editors/gvim/unix/unix.factor deleted file mode 100644 index 3e2a42e6e5..0000000000 --- a/basis/editors/gvim/unix/unix.factor +++ /dev/null @@ -1,7 +0,0 @@ -USING: kernel namespaces editors.gvim system ; -IN: editors.gvim.unix - -M: unix gvim-path - \ gvim-path get-global [ - "gvim" - ] unless* ; diff --git a/basis/editors/gvim/windows/windows.factor b/basis/editors/gvim/windows/windows.factor index 3fe228a403..380e6bb54f 100644 --- a/basis/editors/gvim/windows/windows.factor +++ b/basis/editors/gvim/windows/windows.factor @@ -1,10 +1,6 @@ -USING: editors.gvim io.files kernel namespaces sequences -windows.shell32 io.directories.search.windows system -io.pathnames ; +USING: editors.gvim io.directories.search.windows sequences +system ; IN: editors.gvim.windows -M: windows gvim-path - \ gvim-path get-global [ - "vim" [ "gvim.exe" tail? ] find-in-program-files - [ "gvim.exe" ] unless* - ] unless* ; +M: windows find-gvim-path + "vim" [ "gvim.exe" tail? ] find-in-program-files ; diff --git a/basis/editors/macvim/macvim.factor b/basis/editors/macvim/macvim.factor index 6dcf724e8e..f67bf141a7 100644 --- a/basis/editors/macvim/macvim.factor +++ b/basis/editors/macvim/macvim.factor @@ -1,10 +1,8 @@ -USING: definitions io.launcher kernel math math.parser parser -namespaces prettyprint editors make ; +USING: editors.vim kernel namespaces ; IN: editors.macvim -: macvim ( file line -- ) - drop - [ "open" , "-a" , "MacVim", , ] { } make - run-detached drop ; +SINGLETON: macvim +macvim \ vim-editor set-global -[ macvim ] edit-hook set-global +M: macvim vim-path \ vim-path get-global "mvim" or ; +M: macvim vim-detached? t ; diff --git a/basis/editors/vim/vim.factor b/basis/editors/vim/vim.factor index 55c3889e00..33e596e1ad 100644 --- a/basis/editors/vim/vim.factor +++ b/basis/editors/vim/vim.factor @@ -1,23 +1,31 @@ -USING: definitions io io.launcher kernel math math.parser -namespaces parser prettyprint sequences editors accessors -make strings ; +USING: editors io.backend io.launcher kernel make math.parser +namespaces sequences strings system vocabs.loader ; IN: editors.vim -SYMBOL: vim-path SYMBOL: vim-editor -HOOK: vim-command vim-editor ( file line -- array ) SINGLETON: vim +\ vim vim-editor set-global -M: vim vim-command +SYMBOL: vim-path + +HOOK: find-vim-path vim-editor ( -- path ) +HOOK: vim-detached? vim-editor ( -- detached? ) + + +M: vim find-vim-path "vim" ; +M: vim vim-detached? f ; + +: actual-vim-path ( -- path ) + \ vim-path get-global [ find-vim-path ] unless* ; + +: vim-command ( file line -- command ) [ - vim-path get dup string? [ , ] [ % ] if + actual-vim-path dup string? [ , ] [ % ] if [ , ] [ number>string "+" prepend , ] bi* ] { } make ; : vim ( file line -- ) - vim-command run-process drop ; + vim-command vim-detached? [ run-detached ] [ run-process ] if drop ; -"vim" vim-path set-global [ vim ] edit-hook set-global -\ vim vim-editor set-global