xq-lsp 1.8.3-next.485 → 1.9.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +89 -77
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.0](https://github.com/DrRataplan/xq-lsp/compare/lsp-v1.8.2...lsp-v1.9.0) (2026-11-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * add 'xq-lsp lint' CLI for standalone linting ([#190](https://github.com/DrRataplan/xq-lsp/issues/190)) ([1e49b0f](https://github.com/DrRataplan/xq-lsp/commit/1e49b0f0a76681d81e9e4f97164472485fcb6a64))
9
+ * add semantic tokens support ([2fa8278](https://github.com/DrRataplan/xq-lsp/commit/2fa827832e6ee89fcbf0480527b34a6863243d46)), closes [#120](https://github.com/DrRataplan/xq-lsp/issues/120)
10
+ * **diagnostics:** opt-in strict cardinality checking ([#188](https://github.com/DrRataplan/xq-lsp/issues/188)) ([f5570ee](https://github.com/DrRataplan/xq-lsp/commit/f5570ee7c2c8a201514c27e1ed325ee518050afb))
11
+ * **diagnostics:** report XQST0048 for declarations outside the module namespace ([#194](https://github.com/DrRataplan/xq-lsp/issues/194)) ([984d2c6](https://github.com/DrRataplan/xq-lsp/commit/984d2c68c3514fe7f5145156b99f6716b5686063))
12
+ * extend type inference with operator rules, built-ins and narrowing ([5c6d9b7](https://github.com/DrRataplan/xq-lsp/commit/5c6d9b77353cbbb6800399aa5c5c21cd91c45201))
13
+ * hint on redundant xmlns declarations with quick fix ([#183](https://github.com/DrRataplan/xq-lsp/issues/183)) ([226e39a](https://github.com/DrRataplan/xq-lsp/commit/226e39aa32dadaef96f6bfc2295458e9821481b9)), closes [#182](https://github.com/DrRataplan/xq-lsp/issues/182)
14
+ * **hover:** show variable types in hover tooltips ([#187](https://github.com/DrRataplan/xq-lsp/issues/187)) ([db813ea](https://github.com/DrRataplan/xq-lsp/commit/db813ea8b2ebf6aedd200b630630a488897c6ddb))
15
+ * infer types through if/else, sequences, FLWOR and more for inlay hints ([a77ccaf](https://github.com/DrRataplan/xq-lsp/commit/a77ccaf0b634e28ebf664ae9d7a543b59f93e180))
16
+ * report duplicate prolog declarations (XQST0032/33/38/39/65-69/111/114) ([ae4832b](https://github.com/DrRataplan/xq-lsp/commit/ae4832b94460dcca2b2e3caf3f0fbf68f7c1907d))
17
+ * report serialization option misuse (XQST0108/0109/0110) ([549ee7b](https://github.com/DrRataplan/xq-lsp/commit/549ee7b7bcdae38584aa40b69a1e9644b5fcf0f9))
18
+ * report unsupported xquery version (XQST0031) ([e3e099b](https://github.com/DrRataplan/xq-lsp/commit/e3e099b3994e2cbca20b46823504b2c287670b31))
19
+ * report XPTY0004 for string/boolean arithmetic operands ([03220ca](https://github.com/DrRataplan/xq-lsp/commit/03220caff5f443fc05d08b227493f821210ac656))
20
+ * support LSP 3.17 pull diagnostics (textDocument/diagnostic) ([87fb7d3](https://github.com/DrRataplan/xq-lsp/commit/87fb7d3d0f661ee5e149f2c95a26f6ccd7a7e3c0))
21
+ * sync eXist-db runtime with a live eXist 7 instance ([#181](https://github.com/DrRataplan/xq-lsp/issues/181)) ([db84a79](https://github.com/DrRataplan/xq-lsp/commit/db84a79309be4b3fa7e29489840369ea1be36c16))
22
+ * use the types of imported and predeclared variables ([1f64aae](https://github.com/DrRataplan/xq-lsp/commit/1f64aaeca9195d8a0998e2836425e1315750f4e4))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **fonto:** declare 13 missing fonto:* runtime functions ([161a0c9](https://github.com/DrRataplan/xq-lsp/commit/161a0c9994015f906787fa550f01547c7fc34788)), closes [#157](https://github.com/DrRataplan/xq-lsp/issues/157)
28
+ * make attributes cardinality `?` if a nametest is given ([#189](https://github.com/DrRataplan/xq-lsp/issues/189)) ([936e804](https://github.com/DrRataplan/xq-lsp/commit/936e804b06f031a8e78251676cac9c618167d590))
29
+ * report XPST0017 for calls into closed-world namespaces ([023e373](https://github.com/DrRataplan/xq-lsp/commit/023e37306c48feaecf66c537e5f0488e9f4c057b))
30
+ * resolve functions from sibling module files sharing a target namespace ([b8042b2](https://github.com/DrRataplan/xq-lsp/commit/b8042b2167ee5f0831bbb04f1e6e1ecaf90072aa)), closes [#158](https://github.com/DrRataplan/xq-lsp/issues/158)
31
+ * skip XPST0008 for variables from unresolved imports and warn at the import ([#180](https://github.com/DrRataplan/xq-lsp/issues/180)) ([0444220](https://github.com/DrRataplan/xq-lsp/commit/04442208d32979b104a9e0193075c2239de7eaa4))
32
+ * treat literal xs:QName/cast/namespace-uri-for-prefix prefixes as namespace uses ([#173](https://github.com/DrRataplan/xq-lsp/issues/173)) ([bf20a58](https://github.com/DrRataplan/xq-lsp/commit/bf20a58f5dfb5324e40d46c67d7a19fcf36143b1))
33
+ * use declared or host-supplied context item for global variable initializers ([#170](https://github.com/DrRataplan/xq-lsp/issues/170)) ([e0f731d](https://github.com/DrRataplan/xq-lsp/commit/e0f731da7326349e21b74d90cf6a0e49775045df))
34
+
3
35
  ## [1.8.2](https://github.com/DrRataplan/xq-lsp/compare/lsp-v1.8.1...lsp-v1.8.2) (2026-09-01)
4
36
 
5
37
 
package/README.md CHANGED
@@ -2,24 +2,31 @@
2
2
 
3
3
  # xq-lsp
4
4
 
5
- Language Server Protocol implementation for XQuery, providing autocompletion, hover documentation, signature help, go-to-definition, and diagnostics — plus an eslint-style command-line linter (`xq-lsp lint`).
5
+ Language Server Protocol implementation for XQuery, providing autocompletion, hover documentation,
6
+ signature help, go-to-definition, and diagnostics — plus an eslint-style command-line linter
7
+ (`xq-lsp lint`).
6
8
 
7
9
  ## Features
8
10
 
9
- - **Syntax highlighting** — keywords, types, variables, operators, comments, and XQuery 4.0 tokens (VS Code extension)
11
+ - **Syntax highlighting** — keywords, types, variables, operators, comments, and XQuery 4.0 tokens
12
+ (VS Code extension)
10
13
  - **Completion** — functions declared in the current file, imported modules, and variables in scope
11
14
  - **Hover** — function signatures on hover
12
15
  - **Signature help** — active parameter hints inside function calls
13
16
  - **Go to definition** — jump to function or variable declarations, including across imported files
14
17
  - **Document symbols** — file outline of all declared functions and variables
15
- - **Diagnostics** — syntax errors, undeclared namespace prefixes, type mismatches, and unused symbols — pushed on change, and also available on request via LSP 3.17 pull diagnostics (`textDocument/diagnostic`), including for files that are not open
16
- - **Command-line linting** — `xq-lsp lint` runs the same diagnostics over files, directories, and globs from the shell, with eslint-style output and exit codes, for CI
18
+ - **Diagnostics** — syntax errors, undeclared namespace prefixes, type mismatches, and unused
19
+ symbols — pushed on change, and also available on request via LSP 3.17 pull diagnostics
20
+ (`textDocument/diagnostic`), including for files that are not open
21
+ - **Command-line linting** — `xq-lsp lint` runs the same diagnostics over files, directories, and
22
+ globs from the shell, with eslint-style output and exit codes, for CI
17
23
 
18
24
  ## Configuration
19
25
 
20
26
  ### Summary: Fonto development
21
27
 
22
- Place an `lsp-config.xq` file in the Fonto root folder (the one that holds the manifest.json) with the following content:
28
+ Place an `lsp-config.xq` file in the Fonto root folder (the one that holds the manifest.json) with
29
+ the following content:
23
30
 
24
31
  ```xquery
25
32
  map {
@@ -33,7 +40,8 @@ map {
33
40
 
34
41
  ### General configuration
35
42
 
36
- Place an `lsp-config.xq` file in your project root to enable glob-based import resolution. The server walks up from the current file's directory to find it.
43
+ Place an `lsp-config.xq` file in your project root to enable glob-based import resolution. The
44
+ server walks up from the current file's directory to find it.
37
45
 
38
46
  The file contains an XPath 3.1 map expression with a `glob` key:
39
47
 
@@ -47,7 +55,9 @@ Multiple patterns are written as an XPath sequence:
47
55
  map {"glob": ("src/**/*.xq", "lib/**/*.xq")}
48
56
  ```
49
57
 
50
- The server expands the globs, analyzes each matched file, and indexes library modules by their declared namespace URI. Imports written without an `at` clause are then resolved by matching the namespace URI:
58
+ The server expands the globs, analyzes each matched file, and indexes library modules by their
59
+ declared namespace URI. Imports written without an `at` clause are then resolved by matching the
60
+ namespace URI:
51
61
 
52
62
  ```xquery
53
63
  (: no "at" path needed — the server finds the file via the glob index :)
@@ -57,16 +67,17 @@ import module namespace util="http://example.com/util";
57
67
  Imports written as `import module namespace prefix="uri" at "./other-file.xq"` are followed
58
68
  automatically; symbols from imported files are included in completions.
59
69
 
60
- For files with syntax errors (common while editing), the server falls back to regex-based extraction so completions keep working.
70
+ For files with syntax errors (common while editing), the server falls back to regex-based extraction
71
+ so completions keep working.
61
72
 
62
73
  ### Runtime built-ins
63
74
 
64
75
  Use the `lib` key to load built-in definitions for a specific runtime:
65
76
 
66
- | Value | Runtime |
77
+ | Value | Runtime |
67
78
  | ----------- | ------------------------------------------------------------------------- |
68
- | `"fonto"` | [Fonto XML editor](https://www.fontoxml.com/) — `fonto:*` functions |
69
- | `"existdb"` | [eXist-db](https://exist-db.org/) — all extension module functions |
79
+ | `"fonto"` | [Fonto XML editor](https://www.fontoxml.com/) — `fonto:*` functions |
80
+ | `"existdb"` | [eXist-db](https://exist-db.org/) — all extension module functions |
70
81
 
71
82
  ```xquery
72
83
  map {"glob": "src/**/*.xq", "lib": "existdb"}
@@ -80,21 +91,20 @@ map {"glob": "src/**/*.xq", "lib": ("fonto", "other")}
80
91
 
81
92
  #### eXist-db runtime
82
93
 
83
- The `"existdb"` runtime bundles stub definitions for every eXist-db extension
84
- module (`util`, `xmldb`, `request`, `sm`, `ft`, `compression`, …).
94
+ The `"existdb"` runtime bundles stub definitions for every eXist-db extension module (`util`,
95
+ `xmldb`, `request`, `sm`, `ft`, `compression`, …).
85
96
 
86
- eXist-db automatically pre-declares a large set of namespace prefixes — you can
87
- call `util:log(…)`, `xmldb:store(…)`, `process:execute(…)`, etc. without any
88
- `import module namespace` statement. When the `existdb` runtime is active the
89
- server knows about these pre-declared prefixes and:
97
+ eXist-db automatically pre-declares a large set of namespace prefixes — you can call `util:log(…)`,
98
+ `xmldb:store(…)`, `process:execute(…)`, etc. without any `import module namespace` statement. When
99
+ the `existdb` runtime is active the server knows about these pre-declared prefixes and:
90
100
 
91
- - **suppresses** false `XQST0081` ("namespace prefix not declared") diagnostics
92
- for all pre-declared namespaces
93
- - **provides completions, hover, and go-to-definition** for those modules
94
- without requiring an explicit `import module namespace` in your source
101
+ - **suppresses** false `XQST0081` ("namespace prefix not declared") diagnostics for all pre-declared
102
+ namespaces
103
+ - **provides completions, hover, and go-to-definition** for those modules without requiring an
104
+ explicit `import module namespace` in your source
95
105
 
96
- If you do choose to write explicit imports (e.g. for editor portability), the
97
- server handles those correctly too:
106
+ If you do choose to write explicit imports (e.g. for editor portability), the server handles those
107
+ correctly too:
98
108
 
99
109
  ```xquery
100
110
  (: explicit import — also fine :)
@@ -102,8 +112,8 @@ import module namespace util = "http://exist-db.org/xquery/util";
102
112
  util:uuid()
103
113
  ```
104
114
 
105
- Modules that require explicit import even in eXist-db (e.g. `console`, `kwic`) still need a `import module
106
- namespace` declaration; the server offers quick-fix code actions to insert it.
115
+ Modules that require explicit import even in eXist-db (e.g. `console`, `kwic`) still need a `import
116
+ module namespace` declaration; the server offers quick-fix code actions to insert it.
107
117
 
108
118
  ```xquery
109
119
  (: lsp-config.xq in your project root :)
@@ -116,13 +126,13 @@ map {
116
126
  }
117
127
  ```
118
128
 
119
- The `generateLocationHints: false()` setting prevents the server from appending
120
- `at "…"` paths to generated imports, which eXist-db does not need (it resolves
121
- modules by namespace URI).
129
+ The `generateLocationHints: false()` setting prevents the server from appending `at "…"` paths to
130
+ generated imports, which eXist-db does not need (it resolves modules by namespace URI).
122
131
 
123
132
  #### Fonto runtime
124
133
 
125
- Then import the namespace in your XQuery files as usual — the server resolves completions, hover, and go-to-definition against the bundled definitions:
134
+ Then import the namespace in your XQuery files as usual — the server resolves completions, hover,
135
+ and go-to-definition against the bundled definitions:
126
136
 
127
137
  ```xquery
128
138
  import module namespace fonto="http://www.fontoxml.com/functions";
@@ -143,11 +153,10 @@ map {
143
153
 
144
154
  ### Strict mode
145
155
 
146
- By default the type checker only reports *certain* static type errors. Some
147
- mistakes are only dynamic errors (XPTY0004) that a static analyzer cannot prove —
148
- for example passing a value of type `item()*` to a parameter declared `as item()`:
149
- the sequence may have length 0 or 2 at runtime. Opt in to stricter checking with
150
- the `strict` map to get these reported as **warnings**:
156
+ By default the type checker only reports *certain* static type errors. Some mistakes are only
157
+ dynamic errors (XPTY0004) that a static analyzer cannot prove — for example passing a value of type
158
+ `item()*` to a parameter declared `as item()`: the sequence may have length 0 or 2 at runtime. Opt
159
+ in to stricter checking with the `strict` map to get these reported as **warnings**:
151
160
 
152
161
  ```xquery
153
162
  map {
@@ -158,17 +167,19 @@ map {
158
167
  }
159
168
  ```
160
169
 
161
- With `"cardinality": true()`, an argument whose inferred cardinality is not
162
- guaranteed to fit the parameter's occurrence indicator is flagged as a warning
163
- (still with code `XPTY0004`). For example, passing `item()*` where `item()` is
164
- expected, or `item()?` where `item()+` is expected. The check respects narrowing:
165
- inside `if (exists($x)) then …` a variable of type `item()*` is treated as
170
+ With `"cardinality": true()`, an argument whose inferred cardinality is not guaranteed to fit the
171
+ parameter's occurrence indicator is flagged as a warning (still with code `XPTY0004`). For example,
172
+ passing `item()*` where `item()` is expected, or `item()?` where `item()+` is expected. The check
173
+ respects narrowing: inside `if (exists($x)) then …` a variable of type `item()*` is treated as
166
174
  `item()+`.
167
175
 
176
+ **This will give false-positives**: scripts that are provable ok, but the analyzer could not infer
177
+ all variables correctly and warns. If you find such false positives, please file them as an issue
178
+ with this project.
179
+
168
180
  ## Command-line linting
169
181
 
170
- The same binary ships an eslint-style linter, `xq-lsp lint`, for use in CI or from
171
- the shell — no editor required:
182
+ ships an eslint-style linter, `xq-lsp lint`, for use in CI or from the shell — no editor required:
172
183
 
173
184
  ```sh
174
185
  xq-lsp lint src/ # lint a directory recursively
@@ -177,22 +188,21 @@ xq-lsp lint ./somewhere/something.xq # lint a single file
177
188
  xq-lsp lint src/ --max-warnings 0 # fail on warnings too (CI)
178
189
  ```
179
190
 
180
- With no arguments, the current directory is linted. Directories are searched
181
- recursively for `.xq`, `.xqm`, `.xql`, and `.xquery` files.
191
+ With no arguments, the current directory is linted. Directories are searched recursively for `.xq`,
192
+ `.xqm`, `.xql`, and `.xquery` files.
182
193
 
183
- The linter runs the exact same diagnostics as the editor — syntax errors,
184
- undeclared variables and namespace prefixes, type errors, and unresolved imports —
185
- plus hint-level checks like unused symbols. It finds the nearest `lsp-config.xq`
186
- per file, so the same configuration (glob index, `lib` runtimes, `strict` mode,
187
- `prefixes`) applies as in the editor. Use `--config` to pin a specific config file:
194
+ The linter runs the exact same diagnostics as the editor — syntax errors, undeclared variables and
195
+ namespace prefixes, type errors, and unresolved imports — plus hint-level checks like unused
196
+ symbols. It finds the nearest `lsp-config.xq` per file, so the same configuration (glob index, `lib`
197
+ runtimes, `strict` mode, `prefixes`) applies as in the editor. Use `--config` to pin a specific
198
+ config file:
188
199
 
189
200
  ```sh
190
201
  xq-lsp lint src/ --config ./ci/lsp-config.xq
191
202
  ```
192
203
 
193
- Output uses eslint's `stylish` format by default; `-f json` and `-f compact` are
194
- available for machine consumption, and `--no-color` (or the `NO_COLOR` environment
195
- variable) disables colors:
204
+ Output uses eslint's `stylish` format by default; `-f json` and `-f compact` are available for
205
+ machine consumption, and `--no-color` (or the `NO_COLOR` environment variable) disables colors:
196
206
 
197
207
  ```
198
208
  src/bad.xq
@@ -201,14 +211,12 @@ src/bad.xq
201
211
  ✖ 1 problem (1 error)
202
212
  ```
203
213
 
204
- Exit codes, like eslint: `0` when clean, `1` when errors are found (or when
205
- warnings exceed `--max-warnings <n>`), and `2` on fatal errors (bad arguments, no
206
- files matched, unreadable file or config). Hints (unused symbols, redundant
207
- namespace declarations, …) are reported but never affect the exit code;
208
- `--quiet` reports errors only.
214
+ Exit codes, like eslint: `0` when clean, `1` when errors are found (or when warnings exceed
215
+ `--max-warnings <n>`), and `2` on fatal errors (bad arguments, no files matched, unreadable file or
216
+ config). Hints (unused symbols, redundant namespace declarations, …) are reported but never affect
217
+ the exit code; `--quiet` reports errors only.
209
218
 
210
- Install with `npm install -g xq-lsp`, or run it without installing via
211
- `npx xq-lsp lint`.
219
+ Install with `npm install -g xq-lsp`, or run it without installing via `npx xq-lsp lint`.
212
220
 
213
221
  ## Roadmap
214
222
 
@@ -244,21 +252,20 @@ Open any `.xq` file and eglot starts the server automatically. Run `M-x eglot` t
244
252
 
245
253
  **Key bindings:**
246
254
 
247
- | Action | Key |
255
+ | Action | Key |
248
256
  | ---------------- | ------------------------------------- |
249
- | Completion | `C-M-i` |
250
- | Hover / docs | `C-c C-d` |
251
- | Signature help | automatic in minibuffer |
252
- | Go to definition | `M-.` |
253
- | Go back | `M-,` |
254
- | Document symbols | `M-x imenu` |
255
- | Diagnostics | `M-x flymake-show-buffer-diagnostics` |
256
-
257
- **Inlay hints** (inferred types after untyped `let`/`for`/`declare variable` names, and
258
- parameter names before call arguments) are shown by `eglot-inlay-hints-mode`, which eglot
259
- turns on automatically since Emacs 29.1. If they don't appear, check that `:inlayHintProvider`
260
- isn't listed in `eglot-ignored-server-capabilities`, or toggle them with
261
- `M-x eglot-inlay-hints-mode`.
257
+ | Completion | `C-M-i` |
258
+ | Hover / docs | `C-c C-d` |
259
+ | Signature help | automatic in minibuffer |
260
+ | Go to definition | `M-.` |
261
+ | Go back | `M-,` |
262
+ | Document symbols | `M-x imenu` |
263
+ | Diagnostics | `M-x flymake-show-buffer-diagnostics` |
264
+
265
+ **Inlay hints** (inferred types after untyped `let`/`for`/`declare variable` names, and parameter
266
+ names before call arguments) are shown by `eglot-inlay-hints-mode`, which eglot turns on
267
+ automatically since Emacs 29.1. If they don't appear, check that `:inlayHintProvider` isn't listed
268
+ in `eglot-ignored-server-capabilities`, or toggle them with `M-x eglot-inlay-hints-mode`.
262
269
 
263
270
  ### With lsp-mode
264
271
 
@@ -282,8 +289,8 @@ lsp-mode does not show inlay hints unless asked to:
282
289
  (setq lsp-inlay-hint-enable t)
283
290
  ```
284
291
 
285
- The reference counts above each function and module variable are code lenses; lsp-mode shows
286
- them by default (`lsp-lens-enable`). Eglot does not support code lenses.
292
+ The reference counts above each function and module variable are code lenses; lsp-mode shows them by
293
+ default (`lsp-lens-enable`). Eglot does not support code lenses.
287
294
 
288
295
  ## VS Code
289
296
 
@@ -313,11 +320,15 @@ npx vsce package
313
320
  code --install-extension xquery-lsp-vscode-*.vsix
314
321
  ```
315
322
 
316
- The extension registers `.xq`, `.xql`, `.xqm`, `.xqy`, and `.xquery` files as XQuery, provides syntax highlighting via a bundled TextMate grammar, and starts `xq-lsp` automatically when you open one.
323
+ The extension registers `.xq`, `.xql`, `.xqm`, `.xqy`, and `.xquery` files as XQuery, provides
324
+ syntax highlighting via a bundled TextMate grammar, and starts `xq-lsp` automatically when you open
325
+ one.
317
326
 
318
327
  ## Claude Code
319
328
 
320
- A plugin lives in [`editors/claude-code/`](./editors/claude-code/) that registers `xq-lsp` as a native LSP server for Claude Code, giving diagnostics, go-to-definition, find-references, and hover for XQuery files.
329
+ A plugin lives in [`editors/claude-code/`](./editors/claude-code/) that registers `xq-lsp` as a
330
+ native LSP server for Claude Code, giving diagnostics, go-to-definition, find-references, and hover
331
+ for XQuery files.
321
332
 
322
333
  Make sure the `xq-lsp` binary is on `PATH`:
323
334
 
@@ -332,4 +343,5 @@ Then, from within Claude Code:
332
343
  /plugin install xquery-lsp@xq-lsp
333
344
  ```
334
345
 
335
- See [`editors/claude-code/README.md`](./editors/claude-code/README.md) for local-development setup and details on what the plugin configures.
346
+ See [`editors/claude-code/README.md`](./editors/claude-code/README.md) for local-development setup
347
+ and details on what the plugin configures.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xq-lsp",
3
- "version": "1.8.3-next.485",
3
+ "version": "1.9.0",
4
4
  "description": "XQuery Language Server Protocol implementation",
5
5
  "license": "MIT",
6
6
  "author": "Martin Middel",