Skip to content

Commit e217e84

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

File tree

7 files changed

+123
-93
lines changed

7 files changed

+123
-93
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: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const esbuildProblemMatcherPlugin = {
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
});
2527
console.log("[watch] build finished");
@@ -29,9 +31,7 @@ const esbuildProblemMatcherPlugin = {
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,
3636
format: "cjs",
3737
minify: production,
@@ -41,9 +41,7 @@ async function main() {
4141
outfile: "dist/extension.js",
4242
external: ["vscode"],
4343
logLevel: "silent",
44-
plugins: [
45-
esbuildProblemMatcherPlugin,
46-
],
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
});

eslint.config.mjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import globals from 'globals';
1+
import globals from "globals";
22

3-
import js from '@eslint/js';
4-
import tseslint from 'typescript-eslint';
5-
import markdown from '@eslint/markdown';
6-
import css from '@eslint/css';
7-
import { defineConfig } from 'eslint/config';
8-
import prettier from 'eslint-plugin-prettier';
3+
import js from "@eslint/js";
4+
import tseslint from "typescript-eslint";
5+
import markdown from "@eslint/markdown";
6+
import css from "@eslint/css";
7+
import { defineConfig } from "eslint/config";
8+
import prettier from "eslint-plugin-prettier";
99

1010
export default defineConfig([
1111
{
12-
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
12+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
1313
plugins: { js, prettier },
14-
extends: ['js/recommended'],
14+
extends: ["js/recommended"],
1515
languageOptions: { globals: { ...globals.browser, ...globals.node } },
1616
},
1717
tseslint.configs.recommended,
1818
{
19-
files: ['**/*.{ts,tsx,js,jsx}'],
19+
files: ["**/*.{ts,tsx,js,jsx}"],
2020
plugins: {
2121
prettier,
2222
},
2323
rules: {
2424
// Allow unused function parameters (disable rule)
25-
'@typescript-eslint/no-unused-vars': 'off',
26-
quotes: ['error', 'double'],
25+
"@typescript-eslint/no-unused-vars": "off",
26+
quotes: ["error", "double"],
2727
},
2828
},
2929
{
30-
files: ['**/*.md'],
30+
files: ["**/*.md"],
3131
plugins: { markdown },
32-
language: 'markdown/gfm',
33-
extends: ['markdown/recommended'],
32+
language: "markdown/gfm",
33+
extends: ["markdown/recommended"],
3434
},
3535
{
36-
files: ['**/*.css'],
36+
files: ["**/*.css"],
3737
plugins: { css },
38-
language: 'css/css',
39-
extends: ['css/recommended'],
38+
language: "css/css",
39+
extends: ["css/recommended"],
4040
},
4141
]);

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",

prettier.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @type {import("prettier").Config}
88
*/
99
export default {
10-
trailingComma: 'es5',
10+
trailingComma: "es5",
1111
tabWidth: 4,
1212
semi: true,
13-
singleQuote: true,
13+
singleQuote: false,
1414
};

src/extension.ts

Lines changed: 75 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,89 @@
11
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)