Home

Awesome

Starlark extension for Visual Studio Code

Vscode extension that adds intelligent editor features for the Starlark language.

<!-- including but not limited to Bazel and Buck files. -->

<img src=https://raw.githubusercontent.com/phgn0/vscode-starlark/master/images/syntax.gif width=734 height=255>

<img src=https://raw.githubusercontent.com/phgn0/vscode-starlark/master/images/funcdoc.gif width=734 height=255>

<img src=https://raw.githubusercontent.com/phgn0/vscode-starlark/master/images/autocomplete.gif width=734 height=255>

<img src=https://raw.githubusercontent.com/phgn0/vscode-starlark/master/images/linting.gif width=734 height=255>

Background

Starlark is becoming a dominant configuration language. Its great features include determinitic and isolated execution, as well as simplicity and great readbility.

While there is editor support for Bazel and Buck's build files, no existing editor extension provides jump-to-definition, linting and code completion for pure Starlark files, specifically its load() statement.

These issues will be solved in the future by Google's Starlark language server, which is not open-source yet. This extension here exists to provide a good experience in the meantime.

Architecture

Because Starlark's syntax is a subset of Python, we could of course try to use existing Python editor extensions - which is exactly what this project does. It only takes a tweak to the supported source file extensions, adjustment to the Python grammar, some AST transformations, disabling python features, correct bundling of the modified libraries and some debugging ;)

Because most Python extension share the same code-intelligence library jedi, these modifications can be applied to other editors relatively easily.

Future features

An editor extension based on Google's language server is the best long-term solution, so I don't plan on investing significant time into this project. Though it may be interesting to add autocomplete for files in the load() statement, and we probably want to support buildifier, Starlark's linting & code formatting tool.

Most importantly, please let me know if something doesn't work.