opencode-qml-lsp 0.1.0 → 0.3.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 +27 -12
- package/src/setup.js +5 -7
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,12 +2,26 @@ import { tool } from "@opencode-ai/plugin";
|
|
|
2
2
|
import { QmlLspSetup } from "./setup.js";
|
|
3
3
|
import { QmlFixTool } from "./fix-tool.js";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const NOISY_WARNINGS = [
|
|
6
|
+
"unqualified",
|
|
7
|
+
"block-scope-var-declaration",
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function filterDiagnostics(diagnostics) {
|
|
11
|
+
if (!diagnostics) return diagnostics;
|
|
12
|
+
console.log("[qml-lsp] Raw diagnostics:", diagnostics.length);
|
|
13
|
+
const filtered = diagnostics.filter(d => {
|
|
14
|
+
const code = d.code?.toString?.() || "";
|
|
15
|
+
const message = d.message || "";
|
|
16
|
+
return !NOISY_WARNINGS.some(noisy => code.includes(noisy) || message.includes(noisy));
|
|
17
|
+
});
|
|
18
|
+
console.log("[qml-lsp] Filtered to:", filtered.length);
|
|
19
|
+
return filtered;
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
export const QmlLspPlugin = async (ctx) => {
|
|
10
23
|
const { project, client, $, directory } = ctx;
|
|
24
|
+
console.log("[qml-lsp] Plugin loaded for:", directory);
|
|
11
25
|
|
|
12
26
|
const setup = QmlLspSetup({ client, $, directory });
|
|
13
27
|
const fixTool = QmlFixTool({ client, $, directory });
|
|
@@ -15,10 +29,10 @@ export const QmlLspPlugin = async (ctx) => {
|
|
|
15
29
|
return {
|
|
16
30
|
tool: {
|
|
17
31
|
qml_setup: tool({
|
|
18
|
-
description: "Run QML project setup: detect qmlls, generate .
|
|
32
|
+
description: "Run QML project setup: detect qmlls, generate .qmllint.ini and LSP config",
|
|
19
33
|
args: {},
|
|
20
34
|
async execute(_args, context) {
|
|
21
|
-
const result =
|
|
35
|
+
const result = setup.run();
|
|
22
36
|
if (!result.success) {
|
|
23
37
|
return `Setup failed: ${result.message}`;
|
|
24
38
|
}
|
|
@@ -26,18 +40,19 @@ export const QmlLspPlugin = async (ctx) => {
|
|
|
26
40
|
`QML setup complete!`,
|
|
27
41
|
``,
|
|
28
42
|
`Found: ${result.qmllsPath}`,
|
|
29
|
-
`PySide6 QML import: ${result.qmlImportPath || "not found
|
|
30
|
-
`.qml files
|
|
43
|
+
`PySide6 QML import: ${result.qmlImportPath || "not found"}`,
|
|
44
|
+
`.qml files: ${result.qmlFileCount}`,
|
|
31
45
|
``,
|
|
32
|
-
`Generated
|
|
33
|
-
result.generatedFiles.map(f => ` - ${f}`).join("\n"),
|
|
34
|
-
``,
|
|
35
|
-
`Next step: Merge the "lsp" block from opencode-qml-lsp.config.json into your opencode.json`,
|
|
46
|
+
`Generated: ${result.generatedFiles.join(", ")}`,
|
|
36
47
|
].join("\n");
|
|
37
48
|
},
|
|
38
49
|
}),
|
|
39
50
|
qml_fix_warnings: fixTool.tool,
|
|
40
51
|
},
|
|
52
|
+
"lsp.client.diagnostics": async (input, output) => {
|
|
53
|
+
console.log("[qml-lsp] diagnostics hook:", input.uri, input.diagnostics?.length);
|
|
54
|
+
output.diagnostics = filterDiagnostics(input.diagnostics);
|
|
55
|
+
},
|
|
41
56
|
};
|
|
42
57
|
};
|
|
43
58
|
|
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) {
|