Skip to content

chrismo/superdb-lsp

Repository files navigation

SuperDB Syntax Highlighting

Syntax highlighting support for SuperDB query languages:

  • SPQ (SuperSQL) - The SuperDB query language

Components

Component Location Purpose
TextMate bundle supersql/spq.tmbundle/ Syntax highlighting (regex-based)
LSP server lsp/ Language server for completions, diagnostics (details)

Supported Editors

Editor Method Status
JetBrains IDEs TextMate Bundles plugin Working
VS Code Extension (coming soon) Planned
Sublime Text TextMate bundle Should work
GitHub Linguist PR Planned

Installation

JetBrains IDEs (IntelliJ, RubyMine, WebStorm, etc.)

  1. Install the TextMate Bundles plugin
  2. Go to SettingsEditorTextMate Bundles
  3. Click + and select the supersql/spq.tmbundle folder from this repository
  4. Click Apply and OK

Note: After making changes to the grammar, you must reload the bundle:

Settings → TextMate Bundles → Remove → Apply → Re-add → Close

Sublime Text

Copy the .tmb bundle folders to your Sublime Text Packages directory.

SPQ Language Features

The grammar supports the full SuperSQL language as defined in the Super compiler:

Comments

// Single-line comment
-- SQL-style comment
/* Multi-line
   block comment */

Declarations

const pi = 3.14159
func double(x): (x * 2)
op myOperator(): (over this | yield {result: x})

Pipeline Operators

from "data.json"
  | where status == "active"
  | cut name, email
  | sort -timestamp
  | head 10

SQL Syntax

SELECT id, name, COUNT(*) AS total
FROM users
WHERE status = 'active'
GROUP BY category
HAVING total > 5
ORDER BY name ASC
LIMIT 100

F-Strings (Template Strings)

f"Hello, {name}!"
f'Count: {count(this)}'

Types

uint8, uint16, uint32, uint64, uint128, uint256
int8, int16, int32, int64, int128, int256
float16, float32, float64, float128, float256
decimal32, decimal64, decimal128, decimal256
bool, bytes, string, ip, net, type, null, duration, time, error

Operators

|>          // Pipe
:=          // Assignment
:: :>       // Type cast
...         // Spread
== != <>    // Comparison
&& || !     // Logical

Grammar Structure

The TextMate grammar (spq.tmLanguage.json) is organized into these scopes:

Scope Description
comment.* Comments (//, --, /* */)
string.* String literals and f-strings
constant.language.* true, false, null
constant.numeric.* Numbers (int, float, hex)
keyword.control.* const, func, op, type
keyword.other.sql.* SQL keywords
keyword.operator.* Operators
support.function.* Built-in functions
support.function.operator.* Pipeline operators
support.function.aggregate.* Aggregate functions
support.type.* Type names

Contributing

Testing Changes

  1. Edit supersql/spq.tmbundle/Syntaxes/spq.tmLanguage.json
  2. Use supersql/sample.spq to verify highlighting
  3. Reload in your editor (see installation notes above)

Adding New Keywords

Keywords are defined in the repository section of the grammar file. To add a new keyword:

  1. Find the appropriate category (functions-builtin, sql-keywords, etc.)
  2. Add the keyword to the regex pattern
  3. Test with a sample file

Reference

Roadmap

  • VS Code extension
  • GitHub Linguist PR for .spq file highlighting
  • Language Server Protocol (LSP) for rich IDE features
  • IntelliJ native plugin

Related Projects

  • SuperDB - The database engine
  • Zui - Desktop app for SuperDB

License

MIT

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages