Skip to content

A Language Server Protocol (LSP) implementation for SurrealDB's query language, SurrealQL.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Ce11an/surrealql-lsp

Repository files navigation

SurrealQL LSP

A Language Server Protocol (LSP) implementation for SurrealDB's query language, SurrealQL.

Work in Progress!

About

SurrealQL LSP is built with Rust and leverages several powerful libraries:

Installation

Development is ongoing, so installation guides are currently limited to Neovim or Visual Studio Code. Either way, clone and change directories to the root of the repository.

Visual Studio Code

Open Visual Studio Code in the root of the repository.

Ensure that you have installed the required node modules:

cd editors/code && npm install && cd ../..

Once installed, you can launch the extension by pressing F5. This will open a new instance of Visual Studio Code. In the new instance, navigate to the examples/test.surql file. Start typing SurrealQL, you should see completions!

Neovim Setup

Add the following Lua script to your Neovim configuration:

local M = {}

local find_rust_bin = function()
  return '<path-to-repo>/surrealql-lsp/target/debug/surrealql-lsp-server'
end

M.start = function()
  vim.lsp.set_log_level 'debug'
  require('vim.lsp.log').set_format_func(vim.inspect)

  local client = vim.lsp.start {
    name = 'surrealql-lsp-server',
    cmd = { find_rust_bin() },
  }

  if not client then
    vim.notify('Failed to start surrealql-lsp-server', vim.log.levels.ERROR)
    return
  end

  vim.lsp.buf_attach_client(0, client)
end

local group = vim.api.nvim_create_namespace 'surrealql-lsp-server'

M.setup = function()
  vim.api.nvim_clear_autocmds { group = group }

  vim.api.nvim_create_autocmd('FileType', {
    group = group,
    pattern = 'surql',
    callback = M.start,
  })
end

return M

Inside the root of the repository, run:

cargo build

Navigate to your test.surql file and run :LspInfo in Neovim to ensure the LSP is attached.

Features

Incremental Parsing

Utilises tree-sitter for efficient incremental parsing.

Code Completion

Provides code completion support to streamline your development workflow - ongoing!

Screenshot 2024-07-02 at 22 32 16

Hover

Hover over SurrealQL keyworks for documentation - ongoing!

Screenshot 2024-07-13 at 20 46 24

Contributions

We welcome contributions! If you find this project interesting and want to help, please consider contributing.

About

A Language Server Protocol (LSP) implementation for SurrealDB's query language, SurrealQL.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published