Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: Language Server Protocol Support #1558

Open
9 of 16 tasks
phated opened this issue Jun 5, 2023 · 1 comment
Open
9 of 16 tasks

Epic: Language Server Protocol Support #1558

phated opened this issue Jun 5, 2023 · 1 comment

Comments

@phated
Copy link
Contributor

phated commented Jun 5, 2023

Noir Language Server Protocol

High-level overview of goals and components

Goals

  • Work natively and in the browser
    The LSP should be developed in a way that allows us to execute it as a child process when called from a local editor, but we should also be able to instantiate it in the browser to support a Noir editing experience without any server communication. This will likely require a “core” component that is free from the native code that can be consumed by native and wasm-targeting code.
  • Use the same toolchain between terminal & extension
    The toolchain that is used in the terminal should be the same as the one available to the LSP clients. We want to avoid situations where a user has Nargo v0.5.2 installed, but the latest extension is providing them with v0.6.0. To solve this, we can add a command to Nargo, such as nargo lsp, which starts a long-running LSP server. The extension will find nargo in the path and run this command for the user. Providing the LSP command in our nargo tooling also provides a nicer experience for editing experiences where the user must start the LSP process themselves.
  • Asynchronous
    LSP servers process client messages asynchronously. A client may send messages out-of-order or may try to cancel a request that is in progress. Ensuring the LSP server is asynchronous ensures we can handle all the message types.
  • No file writing (or non-overlapping outputs)
    The LSP should not write files if at all possible. Since it is a long-running process, it can store files in memory. If it absolutely needs to write files, it should write to a location isolated for just the LSP to avoid file locks—like we’ve all seen with rust-analyzer.

Components

  • Clients
    LSP “clients” are the frontends, such as a VSCode extension, that request information from the LSP. They send messages that conform to the language server protocol and expect responses in the same format. The VSCode team provides a helper library that provides most of this functionality for us, so the first “client” will be implemented inside https://github.com/noir-lang/vscode-noir.
  • Server
    LSP “servers” are the backends that respond to the various messages that the client sends. This usually requires processing files and responding with the message in the format the language server protocol specifies. These servers should be long-lived processes that maintain a cache of data in memory. Upon startup, the server provides the client with a set of features it supports (error messages, inlay hints, goto definition, etc), known as capabilities, so the client knows which types of messages it is allowed to send.

Research

Tasks

  1. enhancement
    phated
  2. doc needed
  3. enhancement lsp
  4. 15 of 16
    enhancement lsp
    kobyhallx
  5. enhancement lsp
  6. enhancement lsp
  7. enhancement lsp
  8. enhancement lsp
  9. enhancement lsp
  10. enhancement lsp
  11. enhancement lsp
    phated
  12. enhancement lsp
  13. enhancement lsp
    phated
  14. bug lsp
    phated
  15. E-MEDIUM P-LOW bug reviewed-Q3-2023
    phated
  16. E-HIGH P-HIGH bug lsp
    phated
@phated phated self-assigned this Jun 5, 2023
@Savio-Sou
Copy link
Collaborator

To devs reading: your contributions are most welcome!

Feel free to drop a comment on any of the tasks listed if you'd like to one on 🧑‍💻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants