Giter VIP home page Giter VIP logo

starlark-lsp's Introduction

starlark-lsp

A language server for Starlark, a Python-inspired configuration language.

Starlark-lsp uses go.lsp.dev and Tree sitter as its main dependencies to implement the LSP/JSON-RPC protocol and Starlark language analysis, respectively. It can either be used as a standalone executable (see pkg/cli) or as a Go library.

Installing

Ensure you have Go 1.18 or greater installed, then check out this repository and run make install.

CLI

The main command for starlark-lsp is starlark-lsp start:

Start the Starlark LSP server.

By default, the server will run in stdio mode: requests should be written to
stdin and responses will be written to stdout. (All logging is _always_ done
to stderr.)

For socket mode, pass the --address option.

Usage:
  starlark-lsp start [flags]

Examples:

# Launch in stdio mode with extra logging
starlark-lsp start --verbose

# Listen on all interfaces on port 8765
starlark-lsp start --address=":8765"

# Provide type-stub style files to parse and treat as additional language
# built-ins. If path is a directory, treat files and directories inside
# like python modules: subdir/__init__.py and subdir.py define a subdir module.
starlark-lsp start --builtin-paths "foo.py" --builtin-paths "/tmp/modules"

Flags:
      --address string              Address (hostname:port) to listen on
      --builtin-paths stringArray   Paths to files and directories to parse and treat as additional language builtins
  -h, --help                        help for start

Global Flags:
      --debug     Enable debug logging
      --verbose   Enable verbose logging

Current Status

Starlark-lsp is bundled and used by Tilt with the tilt lsp command as part of the Tiltfile VS Code extension.

The Tiltfile in this repository can be used while developing the language server functionality for the Tiltfile extension. For more information on how to contribute to the extension, see the CONTRIBUTING.md file in the vscode-tilt repository.

starlark-lsp's People

Contributors

milas avatar nicksieger avatar landism avatar cutecutecat avatar dependabot[bot] avatar

Stargazers

Mads Dam Jakobsen avatar Marco Moschettini avatar George Kontridze avatar  avatar Bartek Pacia avatar Dan Wolf avatar Max Bo avatar Itay Donanhirsh avatar Dustin Blackman avatar rok avatar Xiaoyi avatar Koichi Yoshigoe avatar Shaw Vrana avatar Thomas Ussery avatar Ben Weinstein-Raun avatar Rich Adams avatar Aleksej Kazmin avatar west avatar  avatar frankfanslc avatar Mahmoud Rusty Abdelkader avatar ZhaoBin avatar Howard Lau avatar Juca Da avatar Ce Gao avatar Nikita avatar Koichi Shiraishi avatar Son Luong Ngoc avatar

Watchers

Dan Bentley avatar Nick Santos avatar Itay Donanhirsh avatar  avatar  avatar

starlark-lsp's Issues

Code outline support

For large configuration files it would ease navigation if a code outline (document symbol map) could be provided.

bug: Hover arguments without new line

Sorry for my fault.

single \n in Markdown won't lead to a new line.
ref: https://stackoverflow.com/a/58465541

So a Markdown string

"Set base image\n## Parameters\nos (str): The operating system (i.e. 'ubuntu20.04')\nlanguage (str): The programing language dependency (i.e. 'python3.8')\nimage (Optional[str]): Custom image (i.e. 'python:3.9-slim')"

will become:
image
without any new line.

We would use \\\n instead of \n. I will give a patch soon.

The right string is:

Value: "Set base image\n## Parameters\nos (str): The operating system (i.e. `ubuntu20.04`)\\\nlanguage (str): The programing language dependency (i.e. `python3.8`)\\\nimage (Optional[str]): Custom image (i.e. `python:3.9-slim`)",

Any the right info:
image

feat: Hover could contain more infomation

Hello, I am a developer from tensorchord. We use starlark-lsp as a denepndency to build our LSP Server.
Much thanks for this project and its contributors!

I have a feature recommendation for starlark-lsp. If you think it is acceptable, I would be happy to help on it. If it could be merged, I could upgrade our project to introduce it either.

When we use Python extension, it would display Parameters and Returns for functions.
image

Hovever, starlark-lsp could only show first line(document) for Hover, it would be better for user if Hover could output arguments types.

Related issue: tensorchord/envd-lsp#35

Hover support for custom symbols (variables, constants, functions)

Hover Support for custom symbols would be great, e.g. in the following snippet I would like to hover main and say_hello and get the docstring and function definution, like for builtin symbols.

"""
say something
"""
def say_hello(what):
    print("hello", what)

"""
main func
"""
def main():
    say_hello("name")

main()

feat: Allow space inside argument defenition

var fieldRe = regexp.MustCompile(`^(\S*)\s*:\s*(.*)$`)

starlark-lsp use LUCI docstring parser. Wheile parse an arg line, it doesn't allow any space inside argument, though it might be useful for add some type defenitions.

Examples:
image

We could revised it into ^(\S.*?)\s*:\s*(.*)$, then could support more flexible argument defenition.

image

Related issue: tensorchord/envd#1468

If you think this feature is acceptable, I would be happy to work on it.

Autocomplete for dicts

Autocomplete for dicts would be very good. This would ease the configuration with structured data.

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.