qlue-ls 0.9.1 → 0.10.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/README.md +27 -172
- package/package.json +1 -1
- package/qlue_ls.d.ts +3 -5
- package/qlue_ls.js +6 -25
- package/qlue_ls_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -2,109 +2,29 @@
|
|
|
2
2
|
🦀 Qlue-ls 🦀
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
-
⚡Qlue-ls (pronounced "clueless") is a *blazingly fast* [language server](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification) for [SPARQL](https://de.wikipedia.org/wiki/SPARQL),
|
|
5
|
+
⚡Qlue-ls (pronounced "clueless") is a *blazingly fast* [language server](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification) for [SPARQL](https://de.wikipedia.org/wiki/SPARQL),
|
|
6
|
+
written in Rust 🦀, build for the web.
|
|
6
7
|
|
|
8
|
+
If you want to use Qlue-ls, check out the [documentation](https://docs.qlue-ls.com).
|
|
7
9
|
To learn more about the origin story of this project, read the [blog post](https://ad-blog.cs.uni-freiburg.de/post/qlue-ls-a-sparql-language-server/).
|
|
8
10
|
|
|
9
|
-
# 🚀 Getting Started
|
|
10
|
-
|
|
11
|
-
## 📦 Installation
|
|
12
|
-
|
|
13
|
-
Qlue-ls is available on [crate.io](https://crates.io/crates/qlue-ls):
|
|
14
|
-
|
|
15
|
-
```shell
|
|
16
|
-
cargo install qlue-ls
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
And on [PyPI](https://pypi.org/project/qlue-ls/):
|
|
20
|
-
|
|
21
|
-
```shell
|
|
22
|
-
pipx install qlue-ls
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
You can also build it from source:
|
|
26
|
-
|
|
27
|
-
```shell
|
|
28
|
-
git clone https://github.com/IoannisNezis/Qlue-ls.git
|
|
29
|
-
cd Qlue-ls
|
|
30
|
-
cargo build --release --bin qlue-ls
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## CLI Usage
|
|
34
|
-
|
|
35
|
-
To run Qlue-ls as **formatter** run:
|
|
36
|
-
|
|
37
|
-
```shell
|
|
38
|
-
qlue-ls format <PATH>
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
To run Qlue-ls as **language server** run:
|
|
42
|
-
|
|
43
|
-
```shell
|
|
44
|
-
qlue-ls server
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This will create a language server listening on stdio.
|
|
48
|
-
|
|
49
|
-
## with Neovim
|
|
50
|
-
|
|
51
|
-
After you installed the language server, add this to your `init.lua`:
|
|
52
|
-
|
|
53
|
-
```lua
|
|
54
|
-
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
55
|
-
desc = 'Connect to Qlue-ls',
|
|
56
|
-
pattern = { 'sparql' },
|
|
57
|
-
callback = function()
|
|
58
|
-
vim.lsp.start {
|
|
59
|
-
name = 'qlue-ls',
|
|
60
|
-
cmd = { 'qlue-ls', 'server' },
|
|
61
|
-
root_dir = vim.fn.getcwd(),
|
|
62
|
-
on_attach = function(client, bufnr)
|
|
63
|
-
vim.keymap.set('n', '<leader>f', vim.lsp.buf.format, { buffer = bufnr, desc = 'LSP: ' .. '[F]ormat' })
|
|
64
|
-
end,
|
|
65
|
-
}
|
|
66
|
-
end,
|
|
67
|
-
})
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Open a `.rq` file and check that the buffer is attached to th server:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
:checkhealth lsp
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Configure keymaps in `on_attach` function.
|
|
77
|
-
|
|
78
11
|
# 🚀 Capabilities
|
|
79
12
|
|
|
80
|
-
|
|
13
|
+
Here is a quick overview what Qlue-ls can do.
|
|
14
|
+
A more detailed list can be found in the [documentation](https://docs.qlue-ls.com/03_capabilities/).
|
|
81
15
|
|
|
82
|
-
|
|
16
|
+
## 📐 Formatting
|
|
83
17
|
|
|
84
18
|
Formats SPARQL queries to ensure consistent and readable syntax.
|
|
85
19
|
Customizable options to align with preferred query styles are also implemented.
|
|
86
20
|
|
|
87
21
|
## 🩺 Diagnostics
|
|
88
22
|
|
|
89
|
-
**Status**: Partial support
|
|
90
|
-
|
|
91
23
|
Diagnostics provide feadback on the query.
|
|
92
24
|
Diagnostics come in severity: error, warning and info
|
|
93
25
|
|
|
94
|
-
** provided diagnostics**:
|
|
95
|
-
|
|
96
|
-
| Type | Name | Description |
|
|
97
|
-
|:------------|:----------------------------|:---------------------------------|
|
|
98
|
-
| ❌ error | undefined prefix | a used prefix is not declared |
|
|
99
|
-
| ❌ error | ungrouped select variable | selected variable is not grouped |
|
|
100
|
-
| ❌ error | invalid projection variable | projection variable is taken |
|
|
101
|
-
| ⚠️ warning | unused prefix | a declared prefix is not used |
|
|
102
|
-
| ℹ️ info | uncompacted uri | a raw uncompacted uri is used |
|
|
103
|
-
|
|
104
26
|
## ✨ Completion
|
|
105
27
|
|
|
106
|
-
**Status**: Full support
|
|
107
|
-
|
|
108
28
|
Completion provides suggestions how the query could continue.
|
|
109
29
|
|
|
110
30
|
For completion of subjects, predicates or objects the language server sends
|
|
@@ -114,20 +34,27 @@ completion-queries to the backend and gets the completions from the knowledge-gr
|
|
|
114
34
|
|
|
115
35
|
## 🛠️ Code Actions
|
|
116
36
|
|
|
117
|
-
|
|
37
|
+
Code action suggest complex changes to your input.
|
|
38
|
+
Often in the form of a *quickfix*, to fix a diagnostic.
|
|
39
|
+
|
|
40
|
+
## ℹ️ Hover
|
|
41
|
+
|
|
42
|
+
Get information about a token on hover.
|
|
43
|
+
|
|
44
|
+
## 🕳 Jump
|
|
45
|
+
|
|
46
|
+
Quickly jump to the next or previous important location in the query.
|
|
118
47
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
| declare prefix | declares undeclared prefix (if known) | undeclared prefix |
|
|
123
|
-
| shorten all uri's | shorten all uri's into compacted form | |
|
|
124
|
-
| add to result | add variable to selected result | |
|
|
125
|
-
| filter variable | add filter for this variable | |
|
|
48
|
+
## ❓ operation identification
|
|
49
|
+
|
|
50
|
+
Determine if a operation is a query or update.
|
|
126
51
|
|
|
127
52
|
# ⚙️ Configuration
|
|
128
53
|
|
|
129
54
|
Qlue-ls can be configured through a `qlue-ls.toml` or `qlue-ls.yml` file.
|
|
130
55
|
|
|
56
|
+
Detailed exmplanations can be found in the [documentation](https://docs.qlue-ls.com/04_configuration/).
|
|
57
|
+
|
|
131
58
|
Here is the full default configuration
|
|
132
59
|
```toml
|
|
133
60
|
[format]
|
|
@@ -136,93 +63,21 @@ align_prefixes = true
|
|
|
136
63
|
separate_prolouge = false
|
|
137
64
|
capitalize_keywords = true
|
|
138
65
|
insert_spaces = true
|
|
139
|
-
tab_size =
|
|
66
|
+
tab_size = 2
|
|
140
67
|
where_new_line = true
|
|
141
68
|
filter_same_line = true
|
|
142
69
|
|
|
143
70
|
[completion]
|
|
144
71
|
timeout_ms = 5000
|
|
145
|
-
result_size_limit =
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
# 🌐 use in web
|
|
149
|
-
|
|
150
|
-
If you want to connect from a web-based-editor, you can use this package as well.
|
|
151
|
-
For this purpose this can be compiled to wasm and is available on [npm](https://www.npmjs.com/package/@ioannisnezis/sparql-language-server):
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
```shell
|
|
155
|
-
npm i qlue-ls
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
You will have to wrap this in a Web Worker and provide a language server client.
|
|
159
|
-
There will be more documentation on this in the future...
|
|
160
|
-
|
|
161
|
-
Until then you can check out the demo in ./editor/
|
|
162
|
-
|
|
163
|
-
# 🏗 Development Setup
|
|
164
|
-
|
|
165
|
-
Here is a quick guide to set this project up for development.
|
|
166
|
-
|
|
167
|
-
## Requirements
|
|
168
|
-
|
|
169
|
-
- [rust](https://www.rust-lang.org/tools/install) >= 1.83.0
|
|
170
|
-
- [wasm-pack](https://rustwasm.github.io/wasm-pack/) >= 0.13.1
|
|
171
|
-
- [node & npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) >= 22.14.0 & >= 11.3.0
|
|
172
|
-
- \[Optional\] [just](https://github.com/casey/just)
|
|
173
|
-
- \[Optional\] [watchexec](https://github.com/watchexec/watchexec)
|
|
174
|
-
|
|
175
|
-
## Initial Setup
|
|
176
|
-
|
|
177
|
-
You will only have to do this once.
|
|
178
|
-
|
|
179
|
-
In the `justfile` and `Makefile` you will find the target `init_dev`, run it:
|
|
72
|
+
result_size_limit = 100
|
|
180
73
|
|
|
181
|
-
|
|
182
|
-
|
|
74
|
+
[prefixes]
|
|
75
|
+
add_missing = true
|
|
76
|
+
remove_unused = true
|
|
183
77
|
```
|
|
184
78
|
|
|
185
|
-
or
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
make init_dev
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
It will:
|
|
192
|
-
- install node dependencies
|
|
193
|
-
- build wasm binaries
|
|
194
|
-
- link against local packages
|
|
195
|
-
- run the vite dev server
|
|
196
|
-
|
|
197
|
-
If you don't have [just](https://github.com/casey/just) or [make](https://wiki.ubuntuusers.de/Makefile/) installed:
|
|
198
|
-
|
|
199
|
-
**Install [just](https://github.com/casey/just)**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
## Automatically rebuild on change
|
|
203
|
-
|
|
204
|
-
When developping the cycle is:
|
|
205
|
-
|
|
206
|
-
- Change the code
|
|
207
|
-
- Compile to wasm (or run tests)
|
|
208
|
-
- Evaluate
|
|
209
|
-
|
|
210
|
-
To avoid having to run a command each time to Compile I strongly recommend setting up a
|
|
211
|
-
auto runner like [watchexec](https://github.com/watchexec/watchexec).
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
watchexec --restart --exts rs --exts toml just build-wasm
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
or just:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
just watch-and-run build-wasm
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
have fun!
|
|
224
|
-
|
|
225
79
|
# 🙏 Special Thanks
|
|
226
80
|
|
|
227
81
|
* [TJ DeVries](https://github.com/tjdevries) for the inspiration and great tutorials
|
|
228
82
|
* [Chris Biscardi](https://github.com/christopherbiscardi) for teaching me Rust
|
|
83
|
+
* [Hannah Bast](https://ad.informatik.uni-freiburg.de/staff/bast) for the guidance.
|
package/package.json
CHANGED
package/qlue_ls.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export function format_raw(text: string): string;
|
|
4
4
|
export function init_language_server(writer: WritableStreamDefaultWriter): Server;
|
|
5
5
|
export function listen(server: Server, reader: ReadableStreamDefaultReader): Promise<void>;
|
|
6
|
-
export function determine_operation_type(input: string): string;
|
|
7
6
|
export function get_parse_tree(input: string, offset: number): any;
|
|
8
7
|
export class Server {
|
|
9
8
|
private constructor();
|
|
@@ -14,11 +13,10 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
14
13
|
|
|
15
14
|
export interface InitOutput {
|
|
16
15
|
readonly memory: WebAssembly.Memory;
|
|
16
|
+
readonly __wbg_server_free: (a: number, b: number) => void;
|
|
17
17
|
readonly format_raw: (a: number, b: number) => [number, number, number, number];
|
|
18
18
|
readonly init_language_server: (a: any) => number;
|
|
19
19
|
readonly listen: (a: number, b: any) => any;
|
|
20
|
-
readonly determine_operation_type: (a: number, b: number) => [number, number];
|
|
21
|
-
readonly __wbg_server_free: (a: number, b: number) => void;
|
|
22
20
|
readonly get_parse_tree: (a: number, b: number, c: number) => any;
|
|
23
21
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
24
22
|
readonly __externref_table_alloc: () => number;
|
|
@@ -28,8 +26,8 @@ export interface InitOutput {
|
|
|
28
26
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
29
27
|
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
30
28
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
29
|
+
readonly closure1217_externref_shim: (a: number, b: number, c: any) => void;
|
|
30
|
+
readonly closure1587_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
31
|
readonly __wbindgen_start: () => void;
|
|
34
32
|
}
|
|
35
33
|
|
package/qlue_ls.js
CHANGED
|
@@ -254,25 +254,6 @@ export function listen(server, reader) {
|
|
|
254
254
|
return ret;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
/**
|
|
258
|
-
* @param {string} input
|
|
259
|
-
* @returns {string}
|
|
260
|
-
*/
|
|
261
|
-
export function determine_operation_type(input) {
|
|
262
|
-
let deferred2_0;
|
|
263
|
-
let deferred2_1;
|
|
264
|
-
try {
|
|
265
|
-
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
266
|
-
const len0 = WASM_VECTOR_LEN;
|
|
267
|
-
const ret = wasm.determine_operation_type(ptr0, len0);
|
|
268
|
-
deferred2_0 = ret[0];
|
|
269
|
-
deferred2_1 = ret[1];
|
|
270
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
271
|
-
} finally {
|
|
272
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
257
|
/**
|
|
277
258
|
* @param {string} input
|
|
278
259
|
* @param {number} offset
|
|
@@ -286,11 +267,11 @@ export function get_parse_tree(input, offset) {
|
|
|
286
267
|
}
|
|
287
268
|
|
|
288
269
|
function __wbg_adapter_24(arg0, arg1, arg2) {
|
|
289
|
-
wasm.
|
|
270
|
+
wasm.closure1217_externref_shim(arg0, arg1, arg2);
|
|
290
271
|
}
|
|
291
272
|
|
|
292
|
-
function
|
|
293
|
-
wasm.
|
|
273
|
+
function __wbg_adapter_99(arg0, arg1, arg2, arg3) {
|
|
274
|
+
wasm.closure1587_externref_shim(arg0, arg1, arg2, arg3);
|
|
294
275
|
}
|
|
295
276
|
|
|
296
277
|
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
|
|
@@ -419,7 +400,7 @@ function __wbg_get_imports() {
|
|
|
419
400
|
const a = state0.a;
|
|
420
401
|
state0.a = 0;
|
|
421
402
|
try {
|
|
422
|
-
return
|
|
403
|
+
return __wbg_adapter_99(a, state0.b, arg0, arg1);
|
|
423
404
|
} finally {
|
|
424
405
|
state0.a = a;
|
|
425
406
|
}
|
|
@@ -571,8 +552,8 @@ function __wbg_get_imports() {
|
|
|
571
552
|
const ret = false;
|
|
572
553
|
return ret;
|
|
573
554
|
};
|
|
574
|
-
imports.wbg.
|
|
575
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
555
|
+
imports.wbg.__wbindgen_closure_wrapper5441 = function(arg0, arg1, arg2) {
|
|
556
|
+
const ret = makeMutClosure(arg0, arg1, 1218, __wbg_adapter_24);
|
|
576
557
|
return ret;
|
|
577
558
|
};
|
|
578
559
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
package/qlue_ls_bg.wasm
CHANGED
|
Binary file
|