editors.visual-studio-code: try to find "code" then "Code" then... on linux.

locals-and-roots
Doug Coleman 2016-05-11 11:52:40 -07:00
parent 8330256b1d
commit 5d116594e0
1 changed files with 17 additions and 13 deletions

View File

@ -1,8 +1,8 @@
! Copyright (C) 2015 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays editors io.files io.pathnames io.standard-paths
kernel make math.parser memoize namespaces sequences system
tools.which ;
USING: combinators.extras combinators.short-circuit editors
generalizations io.files io.pathnames io.standard-paths kernel
make math.parser memoize namespaces sequences system tools.which ;
IN: editors.visual-studio-code
! Command line arguments
@ -14,10 +14,11 @@ visual-studio-code editor-class set-global
HOOK: find-visual-studio-code-invocation os ( -- array )
MEMO: visual-studio-code-invocation ( -- array )
\ visual-studio-code-invocation get [
find-visual-studio-code-invocation
[ { "code" } ] unless*
] unless* ;
{
[ \ visual-studio-code-invocation get ]
[ find-visual-studio-code-invocation ]
[ "code" ]
} 0|| ;
M: macosx find-visual-studio-code-invocation
"com.microsoft.VSCode" find-native-bundle [
@ -29,14 +30,17 @@ M: macosx find-visual-studio-code-invocation
ERROR: can't-find-visual-studio-code ;
M: linux find-visual-studio-code-invocation
"Code" which [
home "VSCode-linux-x64/Code" append-path
dup exists? [ drop f ] unless
] unless* ;
{
[ "code" which ]
[ "Code" which ]
[ home "VSCode-linux-x64/Code" append-path ]
[ "/usr/share/code/code" ]
} [ [ exists? ] ?1arg ] map-compose 0|| ;
M: windows find-visual-studio-code-invocation
{ "Microsoft VS Code" } "code.exe" find-in-applications
[ f ] unless* ;
{
[ { "Microsoft VS Code" } "code.exe" find-in-applications ]
} 0|| ;
M: visual-studio-code editor-command ( file line -- command )
[