opencode-qml-lsp 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +22 -3
- package/src/setup.js +5 -7
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,6 +2,18 @@ import { tool } from "@opencode-ai/plugin";
|
|
|
2
2
|
import { QmlLspSetup } from "./setup.js";
|
|
3
3
|
import { QmlFixTool } from "./fix-tool.js";
|
|
4
4
|
|
|
5
|
+
const NOISY_WARNINGS = [
|
|
6
|
+
"unqualified",
|
|
7
|
+
"block-scope-var-declaration",
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function filterDiagnostics(diagnostics) {
|
|
11
|
+
return diagnostics.filter(d => {
|
|
12
|
+
const code = d.code?.toString?.() || "";
|
|
13
|
+
return !NOISY_WARNINGS.some(noisy => code.includes(noisy));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* opencode-qml-lsp — QML language server support for OpenCode
|
|
7
19
|
* @type {import('@opencode-ai/plugin').Plugin}
|
|
@@ -15,10 +27,10 @@ export const QmlLspPlugin = async (ctx) => {
|
|
|
15
27
|
return {
|
|
16
28
|
tool: {
|
|
17
29
|
qml_setup: tool({
|
|
18
|
-
description: "Run QML project setup: detect qmlls, generate .
|
|
30
|
+
description: "Run QML project setup: detect qmlls, generate .qmllint.ini and LSP config for the current project",
|
|
19
31
|
args: {},
|
|
20
32
|
async execute(_args, context) {
|
|
21
|
-
const result =
|
|
33
|
+
const result = setup.run();
|
|
22
34
|
if (!result.success) {
|
|
23
35
|
return `Setup failed: ${result.message}`;
|
|
24
36
|
}
|
|
@@ -32,13 +44,20 @@ export const QmlLspPlugin = async (ctx) => {
|
|
|
32
44
|
`Generated files:`,
|
|
33
45
|
result.generatedFiles.map(f => ` - ${f}`).join("\n"),
|
|
34
46
|
``,
|
|
47
|
+
`Note: The qmlls bundled with PySide6 doesn't support .qmllint.ini filtering.`,
|
|
48
|
+
`The plugin filters diagnostics client-side to suppress noisy warnings.`,
|
|
49
|
+
``,
|
|
35
50
|
`Next step: Merge the "lsp" block from opencode-qml-lsp.config.json into your opencode.json`,
|
|
36
51
|
].join("\n");
|
|
37
52
|
},
|
|
38
53
|
}),
|
|
39
54
|
qml_fix_warnings: fixTool.tool,
|
|
40
55
|
},
|
|
56
|
+
"lsp.client.diagnostics": async (input, output) => {
|
|
57
|
+
if (!input.diagnostics) return;
|
|
58
|
+
input.diagnostics = filterDiagnostics(input.diagnostics);
|
|
59
|
+
},
|
|
41
60
|
};
|
|
42
61
|
};
|
|
43
62
|
|
|
44
|
-
export default QmlLspPlugin;
|
|
63
|
+
export default QmlLspPlugin;
|
package/src/setup.js
CHANGED
|
@@ -2,12 +2,10 @@ import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
UnqualifiedAccess=disable
|
|
10
|
-
BlockScopeVarDeclaration=disable
|
|
5
|
+
const QMLLINT_NOTE = `# QML Lint Config Note
|
|
6
|
+
# The qmlls bundled with PySide6 doesn't support .qmllint.ini filtering.
|
|
7
|
+
# The opencode-qml-lsp plugin filters diagnostics client-side instead.
|
|
8
|
+
# This file is kept for reference but not used by the LSP.
|
|
11
9
|
`;
|
|
12
10
|
|
|
13
11
|
const COMMON_QMLLS_PATHS = [
|
|
@@ -54,7 +52,7 @@ export function QmlLspSetup({ client, $$, directory }) {
|
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
function generateQmlint() {
|
|
57
|
-
return
|
|
55
|
+
return QMLLINT_NOTE;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
function generateLspConfig(qmllsPath, qmlImportPath) {
|