Skip to content

Commit 334ebb0

Browse files
authored
Merge pull request #38 from romainmenke/language-extension--considerate-frilled-lizard-d1aef8bd53
Add language extension debugging
2 parents 8ec4f90 + 83bba95 commit 334ebb0

7 files changed

Lines changed: 103 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
grammars/css.tmLanguage.json
3+
testing-util/example.css

.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// A launch configuration that launches the extension inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": [
13+
"${workspaceFolder}/testing-util/example.css",
14+
"--extensionDevelopmentPath=${workspaceFolder}"
15+
],
16+
"preLaunchTask": "prepare-extension-debugging"
17+
}
18+
]
19+
}

.vscode/tasks.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "prepare-extension-debugging",
6+
"type": "npm",
7+
"script": "prepare-extension-debugging",
8+
"isBackground": false,
9+
},
10+
]
11+
}

language-configuration.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"comments": {
3+
// symbols used for start and end a block comment.
4+
"blockComment": [ "/*", "*/" ]
5+
},
6+
// symbols used as brackets
7+
"brackets": [
8+
["{", "}"],
9+
["[", "]"],
10+
["(", ")"]
11+
],
12+
// symbols that are auto closed when typing
13+
"autoClosingPairs": [
14+
["{", "}"],
15+
["[", "]"],
16+
["(", ")"],
17+
["\"", "\""],
18+
["'", "'"]
19+
],
20+
// symbols that can be used to surround a selection
21+
"surroundingPairs": [
22+
["{", "}"],
23+
["[", "]"],
24+
["(", ")"],
25+
["\"", "\""],
26+
["'", "'"]
27+
]
28+
}

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,37 @@
33
"description": "CSS support in VS Code",
44
"version": "0.0.0",
55
"scripts": {
6+
"prepare-extension-debugging": "node ./testing-util/prepare-extension-debugging.mjs ",
67
"test": "node --test ./spec/css-spec.mjs"
78
},
89
"devDependencies": {
910
"cson": "^8.2.0",
1011
"vscode-oniguruma": "^2.0.1",
1112
"vscode-textmate": "^9.0.0"
13+
},
14+
"engines": {
15+
"vscode": "^1.96.0"
16+
},
17+
"contributes": {
18+
"languages": [
19+
{
20+
"id": "css",
21+
"aliases": [
22+
"CSS",
23+
"css"
24+
],
25+
"extensions": [
26+
".css"
27+
],
28+
"configuration": "./language-configuration.json"
29+
}
30+
],
31+
"grammars": [
32+
{
33+
"language": "css",
34+
"scopeName": "source.css",
35+
"path": "./grammars/css.tmLanguage.json"
36+
}
37+
]
1238
}
1339
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import cson from 'cson';
4+
import { fileURLToPath } from 'url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
9+
const file = await fs.promises.readFile(path.join(__dirname, '..', 'grammars', 'css.cson'));
10+
await fs.promises.writeFile(path.join(__dirname, '..', 'grammars', 'css.tmLanguage.json'), cson.createJSONString(cson.parse(file.toString())));
11+
12+
if (!fs.existsSync(path.join(__dirname, '..', 'testing-util', 'example.css'))) {
13+
await fs.promises.writeFile(path.join(__dirname, '..', 'testing-util', 'example.css'), `.foo {\n\tcolor: lime;\n}\n`);
14+
}

0 commit comments

Comments
 (0)