Skip to main content

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 --bin qlue-ls 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:

  1. Static (Keywords, constructs, ...)
  2. Dynamic offline (local defined variables)
  3. Dynamic online (with data from a knowledge-graph)

The implementation is in Stage 2.8.
Dynamic online completion works! At the moment the context is limited to the Tripple the completion is requested from. Next step is to introduce full context sensitivity.

🛠️ 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
add to result add variable to selected result
filter variable add filter for this variable

⚙️ 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 = true
separate_prolouge = false
capitalize_keywords = true
insert_spaces = true
tab_size = 10
where_new_line = true
filter_same_line = true

[completion]
timeout_ms = 5000
result_size_limit = 42

🌐 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...

Until then you can check out the demo in ./editor/

🏗 Development Setup

Here is a quick guide to set this project up for development.

Requirements

Initial Setup

You will only have to do this once.

install node dependencies

cd editor
npm install

build wasm & bindings

If you have just installed:

just build-wasm

If you have make installed:

make wasm

If you don't have just or make installed:

Install just

link against local package

cd pkg
npm link
cd ../editor
npm link qlue-ls

Run application

cd editor
npm run dev

Now the webapp should be running, open the browser on localhost:5173.

Automatically rebuild on change

When developping the cycle is:

  • Change the code
  • Compile to wasm (or run tests)
  • Evaluate

To avoid having to run a command each time to Compile I strongly recommend setting up a auto runner like watchexec.

watchexec --restart --exts rs --exts toml just build-wasm

or just:

just watch-and-run build-wasm

have fun!

🙏 Special Thanks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qlue_ls-0.6.1.tar.gz (721.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qlue_ls-0.6.1-py3-none-manylinux_2_38_x86_64.whl (3.4 MB view details)

Uploaded Python 3manylinux: glibc 2.38+ x86-64

File details

Details for the file qlue_ls-0.6.1.tar.gz.

File metadata

  • Download URL: qlue_ls-0.6.1.tar.gz
  • Upload date:
  • Size: 721.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.1

File hashes

Hashes for qlue_ls-0.6.1.tar.gz
Algorithm Hash digest
SHA256 2db8cec8675fb3c7074606e89deada0369e0d68048c0ce33e40d668256f7eff0
MD5 d0d612d65631e4e8834fc9872ff033e3
BLAKE2b-256 65ec2cf02c086b94631861e1a81eccc00636ea3b25d50dfd6c2ff8d2ae5dab82

See more details on using hashes here.

File details

Details for the file qlue_ls-0.6.1-py3-none-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for qlue_ls-0.6.1-py3-none-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 a6b913a1e0ce449d0cb90230623c4d5dc260e2f0bce08c75adb1469c368a4c60
MD5 f606c60f2cf80007522230f6b2cfbeff
BLAKE2b-256 04461ec0170975e518d196326aebd517915d8d15075fde65459a60be8acb7a3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page