tree: f6ee3c5859f45d6d6e47b8d2df166c5adb7ceeb6 [path history] [tgz]
  1. analysis/
  2. langserver/
  3. scripts/
  4. state/
  5. third_party/
  7. go.mod
  8. main.go
  10. sdk_ensure_file.txt


fidl-lsp is an LSP Language Server for FIDL.

Getting Started

See the VSCode extension README for more information on how to install and setup the FIDL LSP extension in VSCode.


To launch a local test instance of VSCode running the extension:

  1. Follow the Fuchsia: Get Started guide.
  2. Run fx gen and then fx build build/fidl:validate_fidl_project_json to make sure fidl_project.json exists.
  3. Build fidl-lint: fx build host_x64/fidl-lint.
  4. Ensure that you have Go and Node.js installed.
  5. Fetch prebuilts and compile the language server and VSCode extension by running
  6. Open the fidl-misc/vscode-language-fidl/ directory in VSCode, and run the Launch Extension task.


To run tests: go test -p 1 ./...

The -p flag specifies that we don't want tests run in parallel, as some of them write to and read from the filesystem and can collide. If you want to force your tests to be re-run (as test results are cached and not re-run until code in that package has changed), you can run with the flag -count 1.


The general flow of control in the language server goes like this:

  • A request/notification is received in langserver/handler.go
  • If it is a notification (changing state of the open files):
    • The LangHandler tells the FileSystem to make the change
    • The LangHandler triggers a re-analysis by the Analyzer
  • If it is a request for some language feature:
    • The LangHandler dispatches the request to the Analyzer
    • The Analyzer extracts the needed information and returns it
    • The LangHandler sends the response to the client

langserver package

This package includes the core logic of the language server. It deals with LSP specific boilerplate, JSON-RPC messages, etc. It includes the LangHandler type, which handles LSP requests, sends reponses and notifications to the client, and dispatches changes to the state manager or requests for analyses to the Analyzer.

state package

The language server's state management is in the state package. Currently this is just an in memory file system (mapping of editor file names to file text). This could be wrapped in e.g. an RWLock to enable concurrent handling of LSP requests and notifications.

analysis package

The “backend” of the server, which doesn't know about LSP but knows how to compile FIDL and analyze the JSON IR.

Includes the Analyzer type, which maintains a set of compiled FIDL Librarys and their constituent files, dependencies, and build artifacts. Main entry point is Analyzer.Analyze(), which is called every time a file is changed on the client. Analyze recompiles the relevant FIDL library for that file and imports the JSON IR.

The Analyzer compiles FIDL libraries by invoking fidlc in a separate process, gets diagnostics from fidlc and fidl-lint, and uses fidl-format for formatting. It locates dependencies using a fidl_project.json file, the path to which will be configurable in the LSP client extension. fidl_project.json declares all FIDL libraries the language server should be aware of, the paths to their constituent files, the path to their JSON IR, and their dependencies (by library name).

Supported LSP features

This list documents LSP features supported by fidl-lsp.



Text Synchronization


Language Features