Giter Club home page Giter Club logo

bazel-lsp's Introduction

Bazel Lsp

This is a Bazel LSP implementation. The main goal is to allow to rule-writers and build maintainers quick navigation through external rulesets. In short, I wanted to be able to "goto definition" in starlark files.

Overall design

After trying many frameworks, I've settled on:

  • Using Rust as the implementaiton language. I love Rust, and it has solid support for LSP, as well as a Starlark implementation and several python parsers.

  • Using tower_lsp as the LSP framework. It's based on tokio, and built on top of lsp_types and handles all the handshaking and protocol passing. This means that implementing a language server essentially boils down to implementing the LanguageServer trait.

  • Using a python parser to parse starlark. With that, I build an index of declared functions and function calls, which I can then resolve requests against.

  • Uses bazel sync to refresh the workspace, and bazel info execution_root to figure out where to load the external rulesets from.

  • Uses a stripped-down version of the vscode language plugin example https://github.com/microsoft/vscode-extension-samples/tree/master/lsp-sample as the base for VSCode integration, with https://github.com/bazelbuild/vscode-bazel's syntax files.

Current Features

  • Goto definition in functions declared in the same file.
  • Goto definition to files loaded from the workspace.
  • Goto definition to files loaded from a different workspace.
  • Support loading local references ("//:") that happen in external deps.
  • Add tests, at least integration.
  • Autocomplete.
  • Goto definition of symbols that are not functions.
    • TODO Note that we will override outer symbols with inner symbols that have hte same identifier. We should only consider the root scope.
  • Parse loaded files at parse time
  • Model loaded symbols as links to declarations instead of declarations with links. Then put the link-following logic in the document map.
  • Run bazel sync with custom output base on workspace refreshes.
  • Run bazel sync on changes to WORKSPACE.
  • Proper error handling, no more expects.
  • Either integrate with a real vscode plugin, or implement proper UX (e.g. progress bars for syncing).

Disclaimer

As you might have guessed, this project is still in increadibly early stages, I'm building it in my free time. No guarantees given.

This also means that I'm not really looking for contributions right now, as I probably won't have the time to review them. However, all sorts of other feedback is appreciated!

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.