Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 0 additions & 395 deletions AGENT.md

This file was deleted.

140 changes: 61 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ homepage = "https://github.com/semanticweblanguageserver/swls"

[workspace.dependencies]
async-trait = "0.1.89"
lsp-types = "=0.94.1"
bevy_ecs = { version = "0.18", default-features = true, features = [
"multi_threaded"
] }
Expand All @@ -19,7 +20,7 @@ logos = "0.15.1"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
ropey = "1.6.1"
# rdf-parsers = "0.1.8"
rdf-parsers = { version = "0.1.13" }
rdf-parsers = { version = "0.1.14" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.145"
similar = "2.7"
Expand Down Expand Up @@ -63,6 +64,7 @@ members = [
"swls",
"test-utils",
"conformance",
"e2e",
]
resolver = "2"
exclude = ["turtle"]
Expand Down
108 changes: 61 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,90 @@
![LICENSE](https://img.shields.io/badge/License-MIT-8A2BE2)
[![Visual Studio Marketplace Last Updated](https://img.shields.io/visual-studio-marketplace/last-updated/ajuvercr.semantic-web-lsp?label=VSCode%20Extension)](https://marketplace.visualstudio.com/items?itemName=ajuvercr.semantic-web-lsp)

This repo includes the source code for the semantic web language server.
The language server provides IDE like functionality for semantic web languages, including Turtle, TriG, JSON-LD and SPARQL.
**SWLS** is a Language Server Protocol (LSP) server that brings IDE-like tooling — diagnostics,
completion, hover, navigation, refactoring, formatting and highlighting — to Semantic Web
languages: **Turtle**, **TriG**, **JSON-LD** and **SPARQL**.

A live demo can be found [online](https://semanticweblanguageserver.github.io/swls/), built with monaco editors.
Try it instantly, no install required: **[live demo](https://semanticweblanguageserver.github.io/swls/)** (Monaco editor in the browser).

## Documentation
## Install

- [lsp-core](https://semanticweblanguageserver.github.io/swls/docs/lsp_core/index.html)
- [lang-turtle](https://semanticweblanguageserver.github.io/swls/docs/lang_turtle/index.html)
- [lang-jsonld](https://semanticweblanguageserver.github.io/swls/docs/lang_jsonld/index.html)
- [lang-sparql](https://semanticweblanguageserver.github.io/swls/docs/lang_sparql/index.html)
- [lsp-bin](https://semanticweblanguageserver.github.io/swls/docs/swls/index.html)
| Editor | How |
|---|---|
| **VS Code** | Install from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=ajuvercr.semantic-web-lsp) ([source](https://github.com/SemanticWebLanguageServer/swls-vscode)) |
| **NeoVim** | Use the [swls.nvim](https://github.com/SemanticWebLanguageServer/swls.nvim) plugin |
| **JetBrains** | Install from the JetBrains Marketplace ([source](https://github.com/SemanticWebLanguageServer/swls-jetbrains)) |
| **Anything else** | Any LSP-capable editor can run the `swls` binary directly — see [Other editors](#other-editors) |

Details and caveats for each editor are in [Installation](#installation) below.

## Features

### Diagnostics

- Syntax diagnostics
- Undefined prefix diagnostics
- SHACL shape diagnostics

### Completion

- Prefix completion (just start writing the prefix, `foa` completes to `foaf:` and adding the prefix statement)
- Property completion (ordered according to domain)
- Class completion (when writing the object where the prediate is `a`)

### Hover

- Shows additional information about the entities like class

### Rename
| Category | What you get |
|---|---|
| **Diagnostics** | Syntax errors · undefined-prefix errors · unused-prefix warnings · unknown-property-in-closed-namespace warnings · SHACL shape violations |
| **Completion** | Keywords (`@prefix`, `@context`, ...) · prefix names (from bundled LOV/prefix.cc data) · classes · domain-aware properties · cross-document subjects (Turtle) · Components.js parameters (JSON-LD) |
| **Hover** | Inferred RDF type · class & property documentation from the ontology · explanation when a property is only accepted via your allow-list |
| **Navigation** | Go to definition (RDF terms and, for JSON-LD, Components.js modules/parameters) · go to type definition · find references · rename |
| **Code actions** | Add missing prefix declaration · allow-list an unknown property · organize/sort `@prefix` imports (Turtle) · extract/inline a blank node |
| **Formatting** | Document formatting for Turtle and JSON-LD · auto-insert the prefix declaration while typing |
| **Highlighting** | Semantic syntax highlighting |
| **Inlay hints** | Inferred type shown inline next to subjects missing an explicit `rdf:type` |

- Rename terms local to the current file
Every diagnostic and almost every feature above can be **individually enabled or disabled** —
see [Configuration](#configuration).

### Formatting
## Installation

- Format Turtle and JSON-LD
Currently a fluent install is possible for NeoVim and VS Code. Since SWLS speaks the standard
Language Server Protocol, it can be wired into any editor with an LSP client — see
[Other editors](#other-editors) if yours isn't listed below.

### Highlighting
### VS Code

- Enables semantic highlighting
There is a VS Code extension available in the [Marketplace](https://marketplace.visualstudio.com/items?itemName=ajuvercr.semantic-web-lsp).
Source: [SemanticWebLanguageServer/swls-vscode](https://github.com/SemanticWebLanguageServer/swls-vscode).

### JetBrains

## Use the LSP
There is a JetBrains plugin available in the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/27501-swls--turtle-trig-sparql--json-ld-language-server).
Source: [SemanticWebLanguageServer/swls-jetbrains](https://github.com/SemanticWebLanguageServer/swls-jetbrains).

Currently a fluent install is possible for NeoVim and VSCode.
However the language server protocol enables swift integration into other editors.
### NeoVim

### VS Code
A NeoVim plugin is available at [SemanticWebLanguageServer/swls.nvim](https://github.com/SemanticWebLanguageServer/swls.nvim).

Install the semantic web lsp extension ([vscode](https://marketplace.visualstudio.com/items?itemName=ajuvercr.semantic-web-lsp) or [open-vscode](https://open-vsx.org/extension/ajuvercr/semantic-web-lsp)).
The extension starts the lsp from WASM and starts the vscode LSP client.
### Other editors

You can configure the LSP to disable certain languages, this is useful as SPARQL is not fully supported yet, but comes bundled in the LSP.
SWLS is a standard LSP server (stdio transport), so any editor with a generic LSP client
(Sublime Text, Helix, Emacs `lsp-mode`/`eglot`, Kate, ...) can run it directly. Grab the `swls`
binary from the [latest release](https://github.com/semanticweblanguageserver/swls/releases) and
point your editor's LSP client at it for `.ttl`, `.trig`, `.jsonld` and `.sparql`/`.rq` files.

### Jetbrains
## Configuration

A zip of the Jetbrains plugin is available with the latest releases.
To install the plugin you should download the zip (swls-1.1-SNAPSHOT.zip) and go to Settings (ctrl + alt + s) > Plugins > Gear > Install Plugin from Disk and select the file.
Currently the plugin checks the Github releases on each startup to check if the latest binary is installed, and installs the latest binary.
This is not very user friendly, certainly on low quality internet connections.
SWLS reads configuration from the client's `initializationOptions`, plus optional
`.swls/config.json` (workspace) and `~/.config/swls/config.json` (global) files.

PRs are much appreciated on the Jetbrains plugin.
```json
{
"turtle": true,
"sparql": false,
"disabled": ["unused_prefix", "hover_excluded_property"]
}
```

### NeoVim
- `turtle` / `trig` / `jsonld` / `sparql` (default `true`) — enable/disable a language plugin entirely.
- `disabled` — a list of individual diagnostics or LSP (sub-)features to turn off, e.g. just the
"unused prefix" warning, or just hover-on-class without touching the rest of hover.

A NeoVim plugin is available at [SemanticWebLanguageServer/swls.nvim](https://github.com/SemanticWebLanguageServer/swls.nvim).
## Documentation

- [lsp-core](https://semanticweblanguageserver.github.io/swls/docs/lsp_core/index.html)
- [lang-turtle](https://semanticweblanguageserver.github.io/swls/docs/lang_turtle/index.html)
- [lang-jsonld](https://semanticweblanguageserver.github.io/swls/docs/lang_jsonld/index.html)
- [lang-sparql](https://semanticweblanguageserver.github.io/swls/docs/lang_sparql/index.html)
- [lsp-bin](https://semanticweblanguageserver.github.io/swls/docs/swls/index.html)

## Screenshots

Expand All @@ -90,7 +104,7 @@ A NeoVim plugin is available at [SemanticWebLanguageServer/swls.nvim](https://gi

When using the Semantic Web Language Server, please use the following citation:

> A. Vercruysse, J. A. Rojas Melendez, and P. Colpaert, “The semantic web language server: enhancing the developer experience for semantic web practitioners,” in The Semantic Web: 22nd European Semantic Web Conference, ESWC 2025, Proceedings, Part II, Portoroz, Slovenia, 2025, vol. 15719, pp. 210–225.
> A. Vercruysse, J. A. Rojas Melendez, and P. Colpaert, “The semantic web language server : enhancing the developer experience for semantic web practitioners,” in The Semantic Web : 22nd European Semantic Web Conference, ESWC 2025, Proceedings, Part II, Portoroz, Slovenia, 2025, vol. 15719, pp. 210–225.

Bibtex:
```bibtex
Expand Down
1 change: 1 addition & 0 deletions conformance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ homepage.workspace = true
sophia_api.workspace = true
sophia_iri.workspace = true
sophia_turtle = "0.9.0"
rdf-parsers.workspace = true

swls-lang-turtle = { path = "../lang-turtle/" }
swls-core = { path = "../core/" }
Expand Down
32 changes: 16 additions & 16 deletions conformance/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#![allow(non_snake_case)]
use std::{collections::HashSet, str::FromStr as _};

use swls_lang_turtle::lang::{
model::{Term, Triple, Turtle},
parse_source,
// parser2::parse_source as parse_source2,
};
use rdf_parsers::model::{BlankNode, NamedNode, Term, Triple, Turtle};
use swls_lang_turtle::lang::parse_source;

fn check_turtle_defined_prefixes(turtle: Option<&Turtle>) -> bool {
// check defined prefixes
Expand All @@ -15,7 +12,10 @@ fn check_turtle_defined_prefixes(turtle: Option<&Turtle>) -> bool {
prefixes.insert(pref.value().prefix.value().to_string());
}

turtle.triples.iter().all(|t| check_triple(&t, &prefixes))
turtle
.triples
.iter()
.all(|t| check_triple(t.value(), &prefixes))
} else {
true
}
Expand Down Expand Up @@ -66,16 +66,17 @@ pub fn test_syntax(location: &str, is_positive: bool) {
}

fn check_triple(triple: &Triple, defined: &HashSet<String>) -> bool {
if !check_term(&triple.subject, &defined) {
if !check_term(triple.subject.value(), defined) {
return false;
}

for po in &triple.po {
if !check_term(&po.predicate, defined) {
let po = po.value();
if !check_term(po.predicate.value(), defined) {
return false;
}

if !po.object.iter().all(|t| check_term(t, defined)) {
if !po.object.iter().all(|t| check_term(t.value(), defined)) {
return false;
}
}
Expand All @@ -85,22 +86,21 @@ fn check_triple(triple: &Triple, defined: &HashSet<String>) -> bool {

fn check_term(term: &Term, defined: &HashSet<String>) -> bool {
match term {
Term::BlankNode(swls_lang_turtle::lang::model::BlankNode::Unnamed(pos, _, _)) => {
Term::BlankNode(BlankNode::Unnamed(pos, _, _)) => {
for po in pos {
if !check_term(&po.predicate, defined) {
let po = po.value();
if !check_term(po.predicate.value(), defined) {
return false;
}

if !po.object.iter().all(|t| check_term(t, defined)) {
if !po.object.iter().all(|t| check_term(t.value(), defined)) {
return false;
}
}
true
}
Term::NamedNode(swls_lang_turtle::lang::model::NamedNode::Prefixed { prefix, .. }) => {
defined.contains(prefix)
}
Term::Collection(spanneds) => spanneds.iter().all(|t| check_term(t, defined)),
Term::NamedNode(NamedNode::Prefixed { prefix, .. }) => defined.contains(prefix),
Term::Collection(spanneds) => spanneds.iter().all(|t| check_term(t.value(), defined)),
_ => true,
}
}
Expand Down
53 changes: 52 additions & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.1.4 (2026-06-22)

### New Features

- <csr-id-bb4f08bed28af56f776d32f787a459c7325ec47e/> gate features with configuration
- <csr-id-4bad0c7033f9029315e831d5801922f959a64165/> add automatic insert of prefix statements when writing colon
- <csr-id-ece087810771449d6e3e9badcc21b123af613879/> inline and extract blank nodes
- <csr-id-5daeb7fab3c033983ddb34cb6c0518eafcd0cbc1/> add undefined iri's warnings
- <csr-id-b55d2807364d9521378e9d5433ee53d3d6bc8109/> prefix diagnostics
- <csr-id-91c1ad0150e44713d3589bb264d704a4656e4a8a/> move tower_lsp to swls binary
- <csr-id-251a00396498ebe11c4c9632afb72b6dd91dafda/> start rename

### Bug Fixes

- <csr-id-e93ae6e2e86c1cdb634820f09c120663cf898fee/> incorrect json-ld alias marked as unused + fix spans on diagnostics
- <csr-id-3604321f63b609c0095e507c094925d0d49894e5/> improve rename robustness
- <csr-id-91a3739936dfb66c688d161c5264c997020abc86/> remove unused systems
- <csr-id-aeb99acaba4869abdf8c7b8608b48c6ff91e0149/> better timing on the validation to reduce race conditions
- <csr-id-e52d0f65cef812ffeab54b7d110045ce4c74f741/> diagnostics after on change things works way better

### Commit Statistics

<csr-read-only-do-not-edit/>

- 12 commits contributed to the release over the course of 20 calendar days.
- 32 days passed between releases.
- 12 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages

### Commit Details

<csr-read-only-do-not-edit/>

<details><summary>view details</summary>

* **Uncategorized**
- Gate features with configuration ([`bb4f08b`](https://github.com/SemanticWebLanguageServer/swls/commit/bb4f08bed28af56f776d32f787a459c7325ec47e))
- Incorrect json-ld alias marked as unused + fix spans on diagnostics ([`e93ae6e`](https://github.com/SemanticWebLanguageServer/swls/commit/e93ae6e2e86c1cdb634820f09c120663cf898fee))
- Add automatic insert of prefix statements when writing colon ([`4bad0c7`](https://github.com/SemanticWebLanguageServer/swls/commit/4bad0c7033f9029315e831d5801922f959a64165))
- Improve rename robustness ([`3604321`](https://github.com/SemanticWebLanguageServer/swls/commit/3604321f63b609c0095e507c094925d0d49894e5))
- Remove unused systems ([`91a3739`](https://github.com/SemanticWebLanguageServer/swls/commit/91a3739936dfb66c688d161c5264c997020abc86))
- Inline and extract blank nodes ([`ece0878`](https://github.com/SemanticWebLanguageServer/swls/commit/ece087810771449d6e3e9badcc21b123af613879))
- Add undefined iri's warnings ([`5daeb7f`](https://github.com/SemanticWebLanguageServer/swls/commit/5daeb7fab3c033983ddb34cb6c0518eafcd0cbc1))
- Better timing on the validation to reduce race conditions ([`aeb99ac`](https://github.com/SemanticWebLanguageServer/swls/commit/aeb99acaba4869abdf8c7b8608b48c6ff91e0149))
- Diagnostics after on change things works way better ([`e52d0f6`](https://github.com/SemanticWebLanguageServer/swls/commit/e52d0f65cef812ffeab54b7d110045ce4c74f741))
- Prefix diagnostics ([`b55d280`](https://github.com/SemanticWebLanguageServer/swls/commit/b55d2807364d9521378e9d5433ee53d3d6bc8109))
- Move tower_lsp to swls binary ([`91c1ad0`](https://github.com/SemanticWebLanguageServer/swls/commit/91c1ad0150e44713d3589bb264d704a4656e4a8a))
- Start rename ([`251a003`](https://github.com/SemanticWebLanguageServer/swls/commit/251a00396498ebe11c4c9632afb72b6dd91dafda))
</details>

## v0.1.3 (2026-05-20)

### New Features
Expand All @@ -16,7 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<csr-read-only-do-not-edit/>

- 3 commits contributed to the release.
- 4 commits contributed to the release.
- 19 days passed between releases.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
Expand All @@ -28,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<details><summary>view details</summary>

* **Uncategorized**
- Release swls-core v0.1.3, swls-lang-rdf-base v0.1.3, swls-lang-jsonld v0.1.5, swls-lang-sparql v0.1.4, swls-lang-trig v0.1.3, swls v0.2.2 ([`0d1c8c5`](https://github.com/SemanticWebLanguageServer/swls/commit/0d1c8c52d0b7741321109ad22f1f16d53e4f8dc6))
- Adjusting changelogs prior to release of swls-core v0.1.3, swls-lang-rdf-base v0.1.3, swls-lang-jsonld v0.1.5, swls-lang-sparql v0.1.4, swls-lang-trig v0.1.3, swls v0.2.2 ([`4f3e731`](https://github.com/SemanticWebLanguageServer/swls/commit/4f3e731b0301e0b689bfe15e790ad4706a3c84e1))
- Use lov-mirror on github for better response times ([`eb41444`](https://github.com/SemanticWebLanguageServer/swls/commit/eb4144409025da4fba32892e10c207441c882de0))
- Better highlighting ([`9b17ed3`](https://github.com/SemanticWebLanguageServer/swls/commit/9b17ed366f37598da0a9747dc51d552bee891ded))
Expand Down
9 changes: 5 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "swls-core"
description = "Core LSP infrastructure for the Semantic Web Language Server"
keywords = ["lsp", "semantic-web", "rdf", "shacl", "sparql"]
categories = ["development-tools"]
version = "0.1.3"
version = "0.1.4"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -15,8 +15,8 @@ homepage.workspace = true
[features]
default = ["shapes", "tokio"]
shapes = []
tokio = ["tower-lsp/runtime-tokio", "sparql_service", "mie"]
agnostic = ["tower-lsp/runtime-agnostic"]
tokio = ["sparql_service", "mie"]
agnostic = []


[dependencies]
Expand All @@ -29,7 +29,8 @@ serde.workspace = true
serde_json.workspace = true
sophia_api.workspace = true
tracing.workspace = true
tower-lsp.workspace = true
async-trait.workspace = true
lsp-types.workspace = true

dirs = "6"
chrono = { version = "0.4.42", default-features = false, features = ["serde"] }
Expand Down
Loading
Loading