A formatter for SPARQL queries
Project description
🦀 Qlue-ls 🦀
⚡Qlue-ls (pronounced "clueless") is a blazingly fast language server for SPARQL, written in Rust 🦀.
[!CAUTION] This Project is still in an early stage.
Only the format capability is production ready.
The rest is experimental.
🚀 Getting Started
📦 Installation
Qlue-ls is available on crate.io:
cargo install qlue-ls
And on PyPi:
pipx install qlue-ls
You can also build it from source:
git clone https://github.com/IoannisNezis/Qlue-ls.git
cd Qlue-ls
cargo build --release --bin qlue-ls
CLI Usage
To run Qlue-ls as formatter run:
qlue-ls format <PATH>
To run Qlue-ls as language server run:
qlue-ls server
This will create a language server listening on stdio.
with Neovim
After you installed the language server, add this to your init.lua:
vim.api.nvim_create_autocmd({ 'FileType' }, {
desc = 'Connect to Qlue-ls',
pattern = { 'sparql' },
callback = function()
vim.lsp.start {
name = 'qlue-ls',
cmd = { 'qlue-ls', 'server' },
root_dir = vim.fn.getcwd(),
on_attach = function(client, bufnr)
vim.keymap.set('n', '<leader>f', vim.lsp.buf.format, { buffer = bufnr, desc = 'LSP: ' .. '[F]ormat' })
end,
}
end,
})
Open a .rq file and check that the buffer is attached to th server:
:checkhealth lsp
Configure keymaps in on_attach function.
🚀 Capabilities
📐 Formatting
Status: Full support
Formats SPARQL queries to ensure consistent and readable syntax. Customizable options to align with preferred query styles are also implemented.
🩺 Diagnostics
Status: Partial support
** provided diagnostics**:
| Type | Name | Description |
|---|---|---|
| ❌ error | undefined prefix | a used prefix is not declared |
| ⚠️ warning | unused prefix | a declared prefix is not used |
| ℹ️ info | uncompacted uri | a raw uncompacted uri is used |
✨ Completion
Status: Partial support
I split auto-completion into 3 stages:
- Static (Keywords, constructs, ...)
- Dynamic offline (local defined variables)
- Dynamic online (with data from a knowledge-graph)
The implementation is in Stage 1.5. Static completion is done, dynamic offline completion is in development.
🛠️ Code Actions
Status: Partial support
| name | description | diagnostic |
|---|---|---|
| shorten uri | shorten uri into compacted form | uncompacted uri |
| declare prefix | declares undeclared prefix (if known) | undeclared prefix |
| shorten all uri's | shorten all uri's into compacted form |
⚙️ Configuration
Qlue-ls can be configured through a qlue-ls.toml or qlue-ls.yml file.
Here is the full default configuration
[format]
align_predicates = true
align_prefixes = false
separate_prolouge = false
capitalize_keywords = true
insert_spaces = true
tab_size = 2
where_new_line = false
🌐 use in web
If you want to connect from a web-based-editor, you can use this package as well.
For this purpose this can be compiled to wasm and is available on npm:
npm i qlue-ls
You will have to wrap this in a Web Worker and provide a language server client. There will be more documentation on this in the future...
🙏 Special Thanks
- TJ DeVries for the inspiration and great tutorials
- Chris Biscardi for teaching me Rust
- GordianDziwis for providing a sparql-tree-sitter grammar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qlue_ls-0.2.3.tar.gz.
File metadata
- Download URL: qlue_ls-0.2.3.tar.gz
- Upload date:
- Size: 569.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2140bbf54c287b3ce68c101905b2ac0b4552ca10dcae77cb07413b42e827e314
|
|
| MD5 |
08666b409b6a29becb93651278ee37db
|
|
| BLAKE2b-256 |
b04e30c7b0ebf6d101c2f8a1c84529467fb59717fa276557e5728da6558d255a
|
File details
Details for the file qlue_ls-0.2.3-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: qlue_ls-0.2.3-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54f146832103026d87fea1698db9b255fd6a368cc090291c470c32bc526d5a51
|
|
| MD5 |
7624028312236f2ff5ea1610baff558a
|
|
| BLAKE2b-256 |
128ca8e6ee112eaa0f9b6f7682bcc500c65c88c9f1c1c1eecbf0e256d677154c
|