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

Usage

To run qlue-ls as formatter run:

qlue-ls format <PATH>

To run qlue-ls as lanugage server run:

qlue-ls server

This will create a language server listening on stdio.

Connect to 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

Currently provides a few basic diagnostics for syntax errors and simple issues in SPARQL queries. Further enhancements are planned to cover a broader range of semantic and logic-related diagnostics.

Currently provided diagnostics:

  • unused namespace (warning): A declared namespace is not used
  • undefined namespace (error): A used namespace is not declared

Planed diagnostics:

  • path compresion possible (info): A declared namespace is not used

Completion

Status: Rudimentary

Basic auto-completion for SPARQL keywords and variables. Currently not context aware.
Future improvements will expand suggestions to include functions, predicates, and custom completions based on query context.

Code Actions

Status: Planed

Future support for code actions, such as quick fixes and refactoring suggestions, to improve productivity and code quality in SPARQL development.

Planed code actions:

  • Consolidate property paths
  • Refactor iris into namespaces
  • Sort Prefixes

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 purpouse this can be compiled to wasm and is availible 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

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.2.1.tar.gz (568.2 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.2.1-py3-none-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

File details

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

File metadata

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

File hashes

Hashes for qlue_ls-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0426d6f9b9627d9aae4b1a935a5cc0080ff29800bc6b3b59ac26d7f368e03379
MD5 a8d3ae636e8a31bec5df6373c82bd6fc
BLAKE2b-256 b3114bc5a77b8e340d732b0f297b3f70ec80a94204e0d22381937a2ed1e42f65

See more details on using hashes here.

File details

Details for the file qlue_ls-0.2.1-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qlue_ls-0.2.1-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d3806a0435002f0b0be3bc3ef63c32b8bf663937e88f9a6d12ab9fc0b0115952
MD5 5eba012806b212786dd6bb24441b9779
BLAKE2b-256 736df36f371fa6ba4934550c7a8bb08be9773a022b845f4b9d643c0d510ea28d

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