Code Monkey home page Code Monkey logo

luau-lsp's Introduction

Luau Language Server

An implementation of a language server for the Luau programming language.

Getting Started

Install the extension from the marketplace: https://marketplace.visualstudio.com/items?itemName=JohnnyMorganz.luau-lsp

For General Users

The langauge server should be immediately usable for general Luau code after installation. String require support is provided for relative module paths, using require("../module").

Type definitions can be provided by configuring luau-lsp.types.definitionFiles.

If there are specific features you require in the language server for your use case, feel free to open an issue.

For Rojo Users

Rojo instance tree and requiring support is provided by default, and the language server should be able to directly emulate Studio. The extension will automatically populate the latest API types and documentation (which can be disabled by configuring luau-lsp.types.roblox).

To resolve your instance tree and provide module resolution, the language server uses Rojo sourcemaps. The language server will automatically create a sourcemap.json in your workspace root on startup and whenever files are added/created/renamed.

It does this by running the rojo sourcemap command, hence Rojo 7.1.0+ must be available to execute in your workspace root. It is recommend to .gitignore the sourcemap.json file. In future, the language server will generate the file internally.

Note, if you are using the VSCode extension on macOS, you need to configure the location of the Rojo binary at luau-lsp.sourcemap.rojoPath.

By default we generate a sourcemap for a default.project.json project file. The name can be changed in extension settings, as well as whether non-script instances are included in the sourcemap (included by default). Autogeneration of sourcemaps can also be toggled completely on/off in settings - the server will instead just listen to manual changes to sourcemap.json files.

Standalone

The tool can run standalone, similar to luau-analyze, to provide type and lint warnings in CI, with full Rojo resolution and API types support. The entry point for the analysis tool is luau-lsp analyze.

Install the binary and run luau-lsp --help for more information.

Design Goals

The initial goal is to develop a language server supporting all common LSP functions. Module resolution and typing will initially revolve around Rojo.

The idea is to ensure module resolution is customisable, allowing the server to later be easily extended to support other environments where Luau may be used. We could also potentially take it a step forward, allowing the server to be used on an Lua 5.1 codebase through a translation layer (such as type comments through EmmyLua), allowing the language server to support general purpose Lua development powered by the Luau type inference engine.

If you use Luau in a different environment and are interested in using the language server, please get in touch!

Supported Features

  • Diagnostics (incl. type errors)
  • Autocompletion
  • Hover
  • Signature Help
  • Go To Definition
  • Go To Type Definition
  • Find References
  • Document Highlight
  • Document Link
  • Document Symbol
  • Color Provider
  • Rename
  • Folding Range
  • Selection Range
  • Call Hierarchy
  • Semantic Tokens
  • Inlay Hints
  • Workspace Symbols

The following are extra features defined in the LSP specification, but most likely do not apply to Luau or are not necessary. They can be investigated at a later time:

  • Go To Declaration (do not apply)
  • Go To Implementation (do not apply)
  • Code Actions (not necessary - could potentially add "fixers" for lints)
  • Code Lens (not necessary)
  • Inline Value (applies for debuggers only)
  • Moniker
  • Formatting (see stylua)
  • Type Hierarchy (Luau currently does not provide any [public] ways to define type hierarchies)

Build From Source

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --target luau-lsp --config Release

luau-lsp's People

Contributors

filiptibell avatar github-actions[bot] avatar johnnymorganz avatar

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.