1 ! Copyright (C) 2015 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators combinators.short-circuit editors
4 generalizations io.files io.pathnames io.standard-paths kernel
5 make math.parser namespaces sequences system tools.which ;
6 IN: editors.visual-studio-code
8 ! Command line arguments
9 ! https://code.visualstudio.com/docs/editor/command-line
11 TUPLE: visual-studio-code ;
12 T{ visual-studio-code } editor-class set-global
14 HOOK: find-visual-studio-code-path editor-class ( -- path )
16 M: visual-studio-code find-visual-studio-code-path
22 [ "~/VSCode-linux-x64/Code" ]
23 [ "/usr/share/code/code" ]
24 } [ dup file-exists? [ drop f ] unless ] map-compose 0|| ] }
26 "com.microsoft.VSCode" find-native-bundle
27 [ "Contents/MacOS/Electron" append-path ] [ f ] if* ] }
28 { windows [ "code.cmd" ] }
31 : visual-studio-code-invocation ( -- path )
33 [ \ visual-studio-code-invocation get ]
34 [ find-visual-studio-code-path ]
38 ERROR: can't-find-visual-studio-code ;
40 : visual-studio-code-editor-command ( file line -- seq )
42 visual-studio-code-invocation
43 [ , ] [ can't-find-visual-studio-code ] if*
45 number>string ":" glue ,
48 M: visual-studio-code editor-command
49 visual-studio-code-editor-command ;