]> gitweb.factorcode.org Git - factor.git/commitdiff
editors: adding EDITOR: syntax and use classes instead of tuples
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 5 Aug 2022 23:15:56 +0000 (16:15 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 5 Aug 2022 23:15:56 +0000 (16:15 -0700)
basis/editors/editors-docs.factor
basis/editors/editors.factor
basis/editors/gvim/gvim.factor
basis/editors/macvim/macvim.factor
basis/editors/vim/vim.factor
basis/editors/visual-studio-code-exploration/visual-studio-code-exploration.factor
basis/editors/visual-studio-code-insiders/visual-studio-code-insiders.factor
basis/editors/visual-studio-code/visual-studio-code.factor
basis/editors/visual-studio-codium/visual-studio-codium.factor

index a67d16b003306705536b42e28a8e72ed8f982be9..1570bd7958cc4986a6e2370e757fa35140e44426 100644 (file)
@@ -9,7 +9,7 @@ ARTICLE: "editor" "Editor integration"
 { $code "USE: editors.emacs" }
 "If you intend to always use the same editor, it helps to have it load during stage 2 bootstrap. Place the code to load and possibly configure it in the " { $link ".factor-boot-rc" } "."
 $nl
-"Editor integration vocabularies store a class or tuple in a global variable when loaded:"
+"Editor integration vocabularies store an object in a global variable when loaded:"
 { $subsections editor-class }
 "If a syntax error was thrown while loading a source file, you can jump to the location of the error in your editor:"
 { $subsections :edit } ;
index 48df40246bdb4996f4c78140b42e7f02a6d2eb36..36c59dc385f1ac0276e593f766786ec8ed6423d5 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs calendar continuations debugger
-definitions io io.launcher io.pathnames kernel namespaces
-prettyprint sequences source-files.errors splitting strings
+definitions io io.launcher io.pathnames kernel lexer namespaces
+prettyprint sequences sets source-files.errors splitting strings
 threads tools.crossref vocabs vocabs.files vocabs.hierarchy
 vocabs.loader vocabs.metadata words ;
 IN: editors
@@ -10,12 +10,16 @@ IN: editors
 SYMBOL: editor-class
 
 : available-editors ( -- seq )
-    "editors" disk-child-vocab-names ;
+    "editors" disk-child-vocab-names
+    { "editors.ui" "editors.private" } diff ;
 
 : editor-restarts ( -- alist )
     available-editors
     [ [ "Load " prepend ] keep ] { } map>assoc ;
 
+SYNTAX: EDITOR:
+    f editor-class set-global "editors." scan-token append reload ;
+
 HOOK: editor-command editor-class ( file line -- command )
 
 M: f editor-command
index 756fdcc7224765167e6b9effe1519b40c4fb18c0..f230ada60367f5e88e1fafe27d76bf2c0b7da613 100644 (file)
@@ -5,9 +5,12 @@ IN: editors.gvim
 ! This code builds on the code in editors.vim; see there for
 ! more information.
 
-TUPLE: gvim < vim ;
+SINGLETON: gvim
 
-editor-class [ T{ gvim } ] initialize
+INSTANCE: gvim vim-base
+
+editor-class get-global dup [ vim? not ] when
+[ gvim editor-class set-global ] unless
 
 HOOK: find-gvim-path io-backend ( -- path )
 
index ef4427fb901f9604c614f37cf768f1b4dfeee734..cc3267fdb67ca2d96555f3a31dc0af003e180d94 100644 (file)
@@ -2,9 +2,12 @@ USING: editors editors.vim io.pathnames io.standard-paths kernel
 namespaces ;
 IN: editors.macvim
 
-TUPLE: macvim < vim ;
+SINGLETON: macvim
 
-editor-class [ T{ macvim } ] initialize
+INSTANCE: macvim vim-base
+
+editor-class get-global dup [ vim? not ] when
+[ macvim editor-class set-global ] unless
 
 : find-macvim-bundle-path ( -- path/f )
     "org.vim.MacVim" find-native-bundle [
index 39d20c41d1bb0efc7b326a96b10761585d73effb..e44d80b70982497774cd4f48daa42dd67cf1305a 100644 (file)
@@ -2,9 +2,13 @@ USING: editors io.standard-paths kernel make math.parser
 namespaces sequences strings ;
 IN: editors.vim
 
-TUPLE: vim ;
+SINGLETON: vim
 
-editor-class [ T{ vim } ] initialize
+MIXIN: vim-base
+
+INSTANCE: vim vim-base
+
+editor-class [ vim ] initialize
 
 SYMBOL: vim-path
 
@@ -14,14 +18,14 @@ HOOK: vim-ui? editor-class ( -- ? )
 
 SYMBOL: vim-tabs?
 
-M: vim vim-ui? f ;
+M: vim-base vim-ui? f ;
 
-M: vim find-vim-path "vim" ?find-in-path ;
+M: vim-base find-vim-path "vim" ?find-in-path ;
 
 : actual-vim-path ( -- path )
     \ vim-path get [ find-vim-path ] unless* ;
 
-M: vim editor-command
+M: vim-base editor-command
     [
         actual-vim-path dup string? [ , ] [ % ] if
         vim-ui? [ "-g" , ] when
@@ -30,4 +34,4 @@ M: vim editor-command
         ,
     ] { } make ;
 
-M: vim editor-detached? f ;
+M: vim-base editor-detached? f ;
index 0d507f9aa9b3fde1f63d37c1e14b55d70f36951b..2f848afb0ed515c33a72ae5f3b1e5970bdd94671 100644 (file)
@@ -5,9 +5,12 @@ io.pathnames io.standard-paths kernel namespaces system
 tools.which ;
 IN: editors.visual-studio-code-exploration
 
-TUPLE: visual-studio-code-exploration < visual-studio-code ;
+SINGLETON: visual-studio-code-exploration
 
-editor-class [ T{ visual-studio-code-exploration } ] initialize
+INSTANCE: visual-studio-code-exploration visual-studio-code-base
+
+editor-class get-global dup [ visual-studio-code? not ] when
+[ visual-studio-code-exploration editor-class set-global ] unless
 
 M: visual-studio-code-exploration find-visual-studio-code-path
     os {
index 48678de0966627e1221382ddcf809f714c909b17..24328975c27145fa2f06595f6ba4146185cbc153 100644 (file)
@@ -5,9 +5,12 @@ io.pathnames io.standard-paths kernel namespaces system
 tools.which ;
 IN: editors.visual-studio-code-insiders
 
-TUPLE: visual-studio-code-insiders < visual-studio-code ;
+SINGLETON: visual-studio-code-insiders
 
-editor-class [ T{ visual-studio-code-insiders } ] initialize
+INSTANCE: visual-studio-code-insiders visual-studio-code-base
+
+editor-class get-global dup [ visual-studio-code? not ] when
+[ visual-studio-code-insiders editor-class set-global ] unless
 
 M: visual-studio-code-insiders find-visual-studio-code-path
     os {
index 70880e99e9e240d41b680b075e1edc7e1fcd1097..289ffca8d9436114791b79ec19ed85a3168b2dbd 100644 (file)
@@ -8,13 +8,15 @@ IN: editors.visual-studio-code
 ! Command line arguments
 ! https://code.visualstudio.com/docs/editor/command-line
 
-TUPLE: visual-studio-code ;
+SINGLETON: visual-studio-code
 
-editor-class [ T{ visual-studio-code } ] initialize
+MIXIN: visual-studio-code-base
+
+editor-class [ visual-studio-code ] initialize
 
 HOOK: find-visual-studio-code-path editor-class ( -- path )
 
-M: visual-studio-code find-visual-studio-code-path
+M: visual-studio-code-base find-visual-studio-code-path
     os {
         { linux [
             {
@@ -46,5 +48,5 @@ ERROR: can't-find-visual-studio-code ;
         number>string ":" glue ,
     ] { } make ;
 
-M: visual-studio-code editor-command
+M: visual-studio-code-base editor-command
     visual-studio-code-editor-command ;
index 923001c3753bdfd339d797d851503d90e418376c..32207ed8ec4245aa4bd63b11b4dc118deca4871e 100644 (file)
@@ -5,9 +5,12 @@ io.pathnames io.standard-paths kernel namespaces system
 tools.which ;
 IN: editors.visual-studio-codium
 
-TUPLE: visual-studio-codium < visual-studio-code ;
+SINGLETON: visual-studio-codium
 
-editor-class [ T{ visual-studio-codium } ] initialize
+INSTANCE: visual-studio-codium visual-studio-code-base
+
+editor-class get-global dup [ visual-studio-code? not ] when
+[ visual-studio-codium editor-class set-global ] unless
 
 M: visual-studio-codium find-visual-studio-code-path
     os {