jfecher / ante

A safe, easy systems language

Home Page:http://antelang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create a LSP server for Ante

jfecher opened this issue · comments

Ante needs a Language Server Protocol server to give errors and warnings as users write their programs in LSP compatible editors.

This is obviously quite a large task so it can be broken up into as many smaller tasks as desired. Here's some examples:

  • Create a LSP server skeleton that runs whenever Ante code is opened in an editor
  • Show errors & warnings when a file is saved
  • Implement go to definition
  • Implement go to declaration
  • Implement "hover" action to show a variable's type.

To limit scope somewhat, I can help with any changes needed in the compiler. I also think the LSP's design should start as simple as possible, e.g. only updating when a file is saved to avoid worrying about partially correct programs for now. Ante's current parser is not recoverable so it will not work well on partial files.

Should that be done inside this repository as a separate workspace, or would you prefer having the language server in a separate repository completely? In terms of implementing the language server, I think using tower-lsp and the tower-lsp-boilerplate should offer the quickest way to get a functional language server. Are you ok with using a library like that to abstract the lower levels of the language server protocol?

@ehllie I think a separate repository might be best. I'm absolutely in favor of using any libraries for the LSP to make things easier. You can take a look at https://github.com/jfecher/ante-lsp for a possible good starting point (and place to merge things into). It uses tower-lsp and was forked from the boilerplate repo. I haven't looked at it in a while though so I doubt it's in a working state.

I've noticed a couple things that would need to be done for the language server to be effective:

  • Make name resolution and type checking steps produce a list of errors, warnings and notes rather than printing them directly to stderr or panicking.
  • Make the AST not require a lifetime parameter. The lifetime of AST being tied to the lifetime of the Path reference makes it awkward to work with in a language server context, since the filename is created from the request, which only lives inside the body of a function that receives it. If we want the AST to live longer in the cache it needs to take ownership of the path.
  • Fix the unsafe impl Send for ... lines? They are marked with a comment saying TODO: Remove, and it's usually not the best idea to lie to the compiler 😛. Not sure how much of an issue it could be though.