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 SINGLETON: visual-studio-code
13 MIXIN: visual-studio-code-base
15 editor-class [ visual-studio-code ] initialize
17 HOOK: find-visual-studio-code-path editor-class ( -- path )
19 M: visual-studio-code-base find-visual-studio-code-path
25 [ "~/VSCode-linux-x64/Code" ]
26 [ "/usr/share/code/code" ]
27 } [ dup file-exists? [ drop f ] unless ] map-compose 0|| ] }
29 "com.microsoft.VSCode" find-native-bundle
30 [ "Contents/MacOS/Electron" append-path ] [ f ] if* ] }
31 { windows [ "code.cmd" ] }
34 : visual-studio-code-invocation ( -- path )
36 [ \ visual-studio-code-invocation get ]
37 [ find-visual-studio-code-path ]
41 ERROR: can't-find-visual-studio-code ;
43 : visual-studio-code-editor-command ( file line -- seq )
45 visual-studio-code-invocation
46 [ , ] [ can't-find-visual-studio-code ] if*
48 number>string ":" glue ,
51 M: visual-studio-code-base editor-command
52 visual-studio-code-editor-command ;