Skip to content

Commit a20713e

Browse files
authored
Merge pull request #79 from galaxyproject/syntax-highlight
Basic embedded language syntax highlighting
2 parents 6d9642c + d632942 commit a20713e

10 files changed

+1597
-6
lines changed

client/package.json

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,66 @@
2626
"vscode": "^1.34.0"
2727
},
2828
"activationEvents": [
29-
"onLanguage:xml"
29+
"onLanguage:galaxytool"
3030
],
3131
"contributes": {
32+
"languages": [
33+
{
34+
"id": "galaxytool",
35+
"firstLine": "^<tool",
36+
"extensions": [
37+
".xml"
38+
],
39+
"aliases": [
40+
"Galaxy Tool Wrapper"
41+
],
42+
"configuration": "./src/languages/galaxytoolxml.language-configuration.json"
43+
},
44+
{
45+
"id": "cheetah",
46+
"extensions": [
47+
".tmpl"
48+
],
49+
"configuration": "./src/languages/cheetah.language-configuration.json"
50+
},
51+
{
52+
"id": "restructuredtext",
53+
"extensions": [
54+
".rst"
55+
],
56+
"configuration": "./src/languages/restructuredtext.language-configuration.json"
57+
}
58+
],
59+
"grammars": [
60+
{
61+
"language": "galaxytool",
62+
"scopeName": "text.xml.galaxytool",
63+
"path": "./src/syntaxes/galaxytoolxml.tmLanguage.json",
64+
"embeddedLanguages": {
65+
"meta.embedded.block.cheetah": "cheetah",
66+
"meta.embedded.block.restructuredtext": "restructuredtext"
67+
}
68+
},
69+
{
70+
"language": "cheetah",
71+
"scopeName": "source.cheetah",
72+
"path": "./src/syntaxes/cheetah.tmLanguage.json"
73+
},
74+
{
75+
"language": "restructuredtext",
76+
"scopeName": "text.restructuredtext",
77+
"path": "./src/syntaxes/restructuredtext.tmLanguage.json"
78+
},
79+
{
80+
"path": "./src/syntaxes/token.injection.json",
81+
"scopeName": "token.injection",
82+
"injectTo": [
83+
"text.xml.galaxytool",
84+
"source.cheetah",
85+
"text.restructuredtext"
86+
]
87+
}
88+
],
3289
"commands": [
3390
{
3491
"command": "galaxytools.generate.tests",
@@ -83,7 +140,7 @@
83140
},
84141
"snippets": [
85142
{
86-
"language": "xml",
143+
"language": "galaxytool",
87144
"path": "./src/snippets.json"
88145
}
89146
]

client/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const LS_VENV_NAME = "glsenv";
99
export const GALAXY_LS_PACKAGE = "galaxy-language-server";
1010
export const GALAXY_LS = "galaxyls";
1111
export const GALAXY_LS_VERSION = EXTENSION_VERSION; // The Extension and Language Server versions should always match
12+
export const LANGUAGE_ID = "galaxytool"
1213

1314
export const PYTHON_UNIX = "python3";
1415
export const PYTHON_WIN = "python.exe";

client/src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ExtensionContext, window, TextDocument, Position, IndentAction, Languag
55
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient";
66
import { activateTagClosing, TagCloseRequest } from './tagClosing';
77
import { installLanguageServer } from './setup';
8-
import { GALAXY_LS } from './constants';
8+
import { GALAXY_LS, LANGUAGE_ID } from './constants';
99
import { Commands, GeneratedCommandRequest, GeneratedTestRequest, requestInsertSnippet } from './commands';
1010

1111
let client: LanguageClient;
@@ -36,7 +36,7 @@ export async function activate(context: ExtensionContext) {
3636
}
3737

3838
// Configure auto-indentation
39-
languages.setLanguageConfiguration('xml', getIndentationRules());
39+
languages.setLanguageConfiguration(LANGUAGE_ID, getIndentationRules());
4040

4141
context.subscriptions.push(client.start());
4242

@@ -74,8 +74,8 @@ function getClientOptions(): LanguageClientOptions {
7474
return {
7575
// Register the server for xml documents
7676
documentSelector: [
77-
{ scheme: "file", language: "xml" },
78-
{ scheme: "untitled", language: "xml" },
77+
{ scheme: "file", language: LANGUAGE_ID },
78+
{ scheme: "untitled", language: LANGUAGE_ID },
7979
],
8080
outputChannelName: "[galaxyls]",
8181
synchronize: {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"comments": {
3+
// symbol used for single line comment. Remove this entry if your language does not support line comments
4+
"lineComment": "##"
5+
},
6+
// symbols used as brackets
7+
"brackets": [
8+
[
9+
"{",
10+
"}"
11+
],
12+
[
13+
"[",
14+
"]"
15+
],
16+
[
17+
"(",
18+
")"
19+
]
20+
],
21+
// symbols that are auto closed when typing
22+
"autoClosingPairs": [
23+
[
24+
"{",
25+
"}"
26+
],
27+
[
28+
"[",
29+
"]"
30+
],
31+
[
32+
"(",
33+
")"
34+
],
35+
[
36+
"\"",
37+
"\""
38+
],
39+
[
40+
"'",
41+
"'"
42+
]
43+
],
44+
// symbols that that can be used to surround a selection
45+
"surroundingPairs": [
46+
[
47+
"{",
48+
"}"
49+
],
50+
[
51+
"[",
52+
"]"
53+
],
54+
[
55+
"(",
56+
")"
57+
],
58+
[
59+
"\"",
60+
"\""
61+
],
62+
[
63+
"'",
64+
"'"
65+
]
66+
]
67+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"comments": {
3+
"blockComment": [
4+
"<!--",
5+
"-->"
6+
]
7+
},
8+
"brackets": [
9+
[
10+
"<!--",
11+
"-->"
12+
],
13+
[
14+
"<",
15+
">"
16+
],
17+
[
18+
"{",
19+
"}"
20+
],
21+
[
22+
"(",
23+
")"
24+
]
25+
],
26+
"autoClosingPairs": [
27+
{
28+
"open": "{",
29+
"close": "}"
30+
},
31+
{
32+
"open": "[",
33+
"close": "]"
34+
},
35+
{
36+
"open": "(",
37+
"close": ")"
38+
},
39+
{
40+
"open": "\"",
41+
"close": "\"",
42+
"notIn": [
43+
"string"
44+
]
45+
},
46+
{
47+
"open": "'",
48+
"close": "'",
49+
"notIn": [
50+
"string"
51+
]
52+
},
53+
{
54+
"open": "<!--",
55+
"close": "-->",
56+
"notIn": [
57+
"comment",
58+
"string"
59+
]
60+
},
61+
{
62+
"open": "<![CDATA[",
63+
"close": "]]>",
64+
"notIn": [
65+
"comment",
66+
"string"
67+
]
68+
}
69+
],
70+
"surroundingPairs": [
71+
{
72+
"open": "'",
73+
"close": "'"
74+
},
75+
{
76+
"open": "\"",
77+
"close": "\""
78+
},
79+
{
80+
"open": "{",
81+
"close": "}"
82+
},
83+
{
84+
"open": "[",
85+
"close": "]"
86+
},
87+
{
88+
"open": "(",
89+
"close": ")"
90+
},
91+
{
92+
"open": "<",
93+
"close": ">"
94+
}
95+
],
96+
"folding": {
97+
"markers": {
98+
"start": "^\\s*<!--\\s*#region\\b.*-->",
99+
"end": "^\\s*<!--\\s*#endregion\\b.*-->"
100+
}
101+
}
102+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"comments": {
3+
"lineComment": ".."
4+
},
5+
"brackets": [
6+
[
7+
"<",
8+
">"
9+
],
10+
[
11+
"[",
12+
"]"
13+
]
14+
],
15+
"autoClosingPairs": [
16+
{
17+
"open": "[",
18+
"close": "]"
19+
},
20+
{
21+
"open": "<",
22+
"close": ">"
23+
}
24+
],
25+
"surroundingPairs": [
26+
[
27+
"*",
28+
"*"
29+
],
30+
[
31+
"|",
32+
"|"
33+
],
34+
[
35+
"`",
36+
"`"
37+
],
38+
[
39+
":",
40+
":"
41+
],
42+
[
43+
"<",
44+
">"
45+
]
46+
],
47+
"folding": {
48+
"offSide": true
49+
}
50+
}

0 commit comments

Comments
 (0)