Skip to content

Commit 75aa6de

Browse files
chore: fmt
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent 8e4933c commit 75aa6de

File tree

5 files changed

+115
-85
lines changed

5 files changed

+115
-85
lines changed

commitlint.config.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
module.exports = {
2-
extends: ["@commitlint/config-conventional"],
3-
rules: {
4-
"type-enum": [2, "always", ["build", "chore", "docs", "feat", "fix", "refactor", "style", "test"]],
5-
"body-max-line-length": [0, "always"],
6-
"footer-max-line-length": [0, "always"],
7-
},
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'build',
9+
'chore',
10+
'docs',
11+
'feat',
12+
'fix',
13+
'refactor',
14+
'style',
15+
'test',
16+
],
17+
],
18+
'body-max-line-length': [0, 'always'],
19+
'footer-max-line-length': [0, 'always'],
20+
},
821
};

esbuild.mjs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
// ESBuild configuration for building the VSCode extension (sample-based)
22
// See: https://github.com/microsoft/vscode-extension-samples/blob/main/esbuild-sample/esbuild.js
33

4-
import * as esbuild from "esbuild";
4+
import * as esbuild from 'esbuild';
55

6-
const production = process.argv.includes("--production");
7-
const watch = process.argv.includes("--watch");
6+
const production = process.argv.includes('--production');
7+
const watch = process.argv.includes('--watch');
88

99
/**
1010
* @type {import('esbuild').Plugin}
1111
*/
1212
const esbuildProblemMatcherPlugin = {
13-
name: "esbuild-problem-matcher",
13+
name: 'esbuild-problem-matcher',
1414
setup(build) {
1515
build.onStart(() => {
16-
console.log("[watch] build started");
16+
console.log('[watch] build started');
1717
});
1818
build.onEnd((result) => {
1919
result.errors.forEach(({ text, location }) => {
2020
console.error(`✘ [ERROR] ${text}`);
2121
if (location) {
22-
console.error(` ${location.file}:${location.line}:${location.column}:`);
22+
console.error(
23+
` ${location.file}:${location.line}:${location.column}:`
24+
);
2325
}
2426
});
25-
console.log("[watch] build finished");
27+
console.log('[watch] build finished');
2628
});
2729
},
2830
};
2931

3032
async function main() {
3133
const ctx = await esbuild.context({
32-
entryPoints: [
33-
"src/extension.ts"
34-
],
34+
entryPoints: ['src/extension.ts'],
3535
bundle: true,
36-
format: "cjs",
36+
format: 'cjs',
3737
minify: production,
3838
sourcemap: !production,
3939
sourcesContent: false,
40-
platform: "node",
41-
outfile: "dist/extension.js",
42-
external: ["vscode"],
43-
logLevel: "silent",
44-
plugins: [
45-
esbuildProblemMatcherPlugin,
46-
],
40+
platform: 'node',
41+
outfile: 'dist/extension.js',
42+
external: ['vscode'],
43+
logLevel: 'silent',
44+
plugins: [esbuildProblemMatcherPlugin],
4745
});
4846
if (watch) {
4947
await ctx.watch();
@@ -53,7 +51,7 @@ async function main() {
5351
}
5452
}
5553

56-
main().catch(e => {
54+
main().catch((e) => {
5755
console.error(e);
5856
process.exit(1);
5957
});

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"watch": "npm run build -- --watch",
2929
"vscode:prepublish": "npm run build -- --production",
3030
"package": "vsce package -o wit-idl.vsix",
31+
"fmt": "prettier . --write",
3132
"lint": "eslint src --ext ts ./*.js ./*.mjs",
3233
"lint-fix": "eslint src --ext ts ./*.js ./*.mjs --fix",
3334
"test": "run-s lint build package test-grammar",
@@ -49,6 +50,7 @@
4950
"eslint-plugin-prettier": "^5.4.0",
5051
"globals": "^16.2.0",
5152
"npm-run-all": "4.1.5",
53+
"prettier": "^3.5.3",
5254
"rimraf": "6.0.1",
5355
"typescript": "5.8.3",
5456
"typescript-eslint": "^8.33.0",

src/extension.ts

Lines changed: 76 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,89 @@
1-
import * as vscode from "vscode";
1+
import * as vscode from 'vscode';
22

33
const builtinTypes = [
4-
"u8",
5-
"u16",
6-
"u32",
7-
"u64",
8-
"s8",
9-
"s16",
10-
"s32",
11-
"s64",
12-
"float32",
13-
"float64",
14-
"char",
15-
"bool",
16-
"string",
17-
"tuple",
18-
"list",
19-
"option",
20-
"result",
21-
"borrow",
4+
'u8',
5+
'u16',
6+
'u32',
7+
'u64',
8+
's8',
9+
's16',
10+
's32',
11+
's64',
12+
'float32',
13+
'float64',
14+
'char',
15+
'bool',
16+
'string',
17+
'tuple',
18+
'list',
19+
'option',
20+
'result',
21+
'borrow',
2222
];
2323

2424
const keywords = [
25-
"_",
26-
"as",
27-
"constructor",
28-
"enum",
29-
"export",
30-
"flags",
31-
"func",
32-
"import",
33-
"include",
34-
"interface",
35-
"package",
36-
"record",
37-
"resource",
38-
"static",
39-
"type",
40-
"use",
41-
"variant",
42-
"with",
43-
"world",
25+
'_',
26+
'as',
27+
'constructor',
28+
'enum',
29+
'export',
30+
'flags',
31+
'func',
32+
'import',
33+
'include',
34+
'interface',
35+
'package',
36+
'record',
37+
'resource',
38+
'static',
39+
'type',
40+
'use',
41+
'variant',
42+
'with',
43+
'world',
4444
];
4545

46-
const staticCompletions = new vscode.CompletionList([
47-
...keywords.map(keyword => new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword)),
48-
...builtinTypes.map(type => new vscode.CompletionItem(type, vscode.CompletionItemKind.Struct)),
49-
], /* isIncomplete: */ true);
46+
const staticCompletions = new vscode.CompletionList(
47+
[
48+
...keywords.map(
49+
(keyword) =>
50+
new vscode.CompletionItem(
51+
keyword,
52+
vscode.CompletionItemKind.Keyword
53+
)
54+
),
55+
...builtinTypes.map(
56+
(type) =>
57+
new vscode.CompletionItem(
58+
type,
59+
vscode.CompletionItemKind.Struct
60+
)
61+
),
62+
],
63+
/* isIncomplete: */ true
64+
);
5065

5166
export function activate(context: vscode.ExtensionContext) {
67+
// VSCode does not support having both its built-in suggestions _and_ a custom completion provider.
68+
// But, without a proper LSP, we do want both!
69+
// Registering the provider directly on "wit" would disable VSCode's built-in suggestions.
70+
// The workaround is to register it for all languages (`*`) and then dynamically check the document type.
71+
const provider = vscode.languages.registerCompletionItemProvider('*', {
72+
provideCompletionItems(
73+
document: vscode.TextDocument,
74+
position: vscode.Position,
75+
token: vscode.CancellationToken,
76+
context: vscode.CompletionContext
77+
) {
78+
if (document.languageId !== 'wit') {
79+
return;
80+
}
5281

53-
// VSCode does not support having both its built-in suggestions _and_ a custom completion provider.
54-
// But, without a proper LSP, we do want both!
55-
// Registering the provider directly on "wit" would disable VSCode's built-in suggestions.
56-
// The workaround is to register it for all languages (`*`) and then dynamically check the document type.
57-
const provider = vscode.languages.registerCompletionItemProvider("*", {
58-
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
59-
if (document.languageId !== "wit") {
60-
return;
61-
}
82+
return staticCompletions;
83+
},
84+
});
6285

63-
return staticCompletions;
64-
}
65-
});
66-
67-
context.subscriptions.push(provider);
86+
context.subscriptions.push(provider);
6887
}
6988

70-
export function deactivate() {
71-
72-
}
89+
export function deactivate() {}

0 commit comments

Comments
 (0)