npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@surrealdb/surrealql-language-server

v0.1.6

Published

Language Server Protocol implementation for SurrealQL

Readme

SurrealQL Language Server

A Language Server Protocol (LSP) implementation for SurrealQL, the query language of SurrealDB.

Features

  • Syntax diagnostics via tree-sitter
  • Semantic analysis with schema inference from DDL and query flow
  • Hover with type info, permission posture, function signatures, and language badges (SurrealQL vs JavaScript)
  • Contextual completions for record<table> types, field names, builtin functions, and statement keywords
  • Go-to definition and references for tables, fields, functions, and params
  • Safe rename of local function definitions
  • Code actions for missing PERMISSIONS clauses
  • Signature help for builtin and user-defined functions
  • Call hierarchy with inbound/outbound function call tracking
  • Document symbols outlining tables, fields, events, indexes, and functions
  • function() { ... } bodies parse cleanly with no false diagnostics; DEFINE FUNCTION bodies containing scripting functions are detected and labelled as JavaScript

Requirements

The language server compiles against a tree-sitter SurrealQL grammar that must be checked out as a sibling directory:

parent/
├── surrealql-language-server/   ← this repo
└── surrealql-tree-sitter/       ← grammar (sibling checkout)

Run the setup script to clone or update the grammar:

bash scripts/setup-grammar.sh

Or set TREE_SITTER_SURREALQL_DIR to point to an existing checkout:

TREE_SITTER_SURREALQL_DIR=/path/to/surrealql-tree-sitter cargo build

Building

cargo build --release
# binary at: target/release/surreal-language-server

Testing

cargo test

Repository Layout

.
├── src/
│   ├── main.rs               # LSP stdio entry point
│   ├── backend.rs            # tower-lsp request handlers
│   ├── config.rs             # workspace settings
│   ├── grammar.rs            # tree-sitter language binding
│   ├── providers/            # completion, hover, rename, etc.
│   └── semantic/
│       ├── analyzer.rs       # document analysis (parse + extract)
│       ├── model.rs          # merged workspace model, code actions
│       ├── types.rs          # DocumentAnalysis, TableDef, FunctionDef, ...
│       ├── type_expr.rs      # SurrealQL type expression parser
│       └── text.rs           # LSP range utilities
├── tests/
│   └── lsp.rs                # integration tests
├── build.rs                  # compiles tree-sitter grammar (C)
└── scripts/
    └── setup-grammar.sh      # clones/updates the grammar sibling repo

Editor Integration

The server communicates over stdio and works with any LSP-compatible editor.

Grammar Development

The tree-sitter grammar lives in the sibling surrealql-tree-sitter repo. After editing grammar.js:

cd ../surrealql-tree-sitter
npx tree-sitter generate
npx tree-sitter test

The src/parser.c is auto-generated and should not be edited directly. JavaScript scripting function bodies (function() { ... }) are handled by an external C scanner at src/scanner.c which tracks brace depth, strings, template literals, and comments.

CI

GitHub Actions runs cargo fmt --check and cargo test on every push and pull request. The grammar sibling repo is cloned automatically during CI.