Giter Site home page Giter Site logo

ce11an / surrealql-lsp Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 243 KB

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

License: Apache License 2.0

Rust 93.10% JavaScript 2.32% TypeScript 4.58%
lsp lsp-server surrealdb surrealql

surrealql-lsp's Introduction

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.

surrealql-lsp's People

Contributors

ce11an avatar voidkandy avatar willlillis avatar

Stargazers

Horváth Bálint avatar Grzegorz Leoniec avatar  avatar Neco avatar Chiru B avatar  avatar  avatar

Watchers

 avatar  avatar

surrealql-lsp's Issues

Context aware completions

After a productive discussion with @WillLillis within a tree-sitter discussion, I have implemented basic context aware completions.

I would like to offer completions for all the grammar specified inside tree-sitter-surrealql.

Completions to start with:

  • All optional nodes inside a from_clause
  • Provide SELECT as a completion if the source code is empty.
  • Restrict completions being repeated, e.g. SELECT VALUE should not provide another VALUE completion.

Another issue is that a query can be over multiple lines. Currently if I write:

SELECT
  *
FROM table
<cursor>

I do not get any completions for WHERE or SPLIT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.