haskell / lsp

Haskell library for the Microsoft Language Server Protocol
360 stars 89 forks source link

Generate types from metamodel #458

Closed michaelpj closed 1 year ago

michaelpj commented 1 year ago

This generates all the LSP types from the LSP metamodel, a new machine-readable format they have produced.

This requires a pretty formidable amount of TH, but in return we get a hopefully much better maintenance process, and we won't always be behind or wrong as we have been. There are also some nice touches, like on GHC >9.2 we can now actually attach doucmentation to things we generate with TH, so we can transfer all the documentation from the metamodel to Haddock.

This is going to result in a lot of churn, enough so that I think it should be a new top-major version of lsp-types. In particular:

This still needs a bunch of work:

Plus a bunch of other TODOs in the code. Any help would be welcome, but here are the top things I'm interested in feedback on:

  1. How does the new version look? Is the organization okay? I'll try and get some Haddock with the new documentation in place soonish so people can look at that without building it.
  2. The gnarly TH. Anyone who wants to dive in is more than welcome, it's not too bad but it would be nice if we could figure out a way to make it less gnarly.
michaelpj commented 1 year ago

@thomasjm @drsooch might be of interest

michaelpj commented 1 year ago

@sjakobi I think you're the main maintainer of the dhall language server, which is one of the main non-HLS users of this package that I know of. I'd really appreciate your thoughts!

michaelpj commented 1 year ago

Guide for reviewers:

sjakobi commented 1 year ago

@sjakobi I think you're the main maintainer of the dhall language server, which is one of the main non-HLS users of this package that I know of. I'd really appreciate your thoughts!

Unfortunately, I'm not very familiar with the dhall-lsp-server internals at all – I've mostly been bumping bounds. Maybe @Gabriella439 has thoughts on this change.

Gabriella439 commented 1 year ago

My take is that you should just do whatever you need to do. We'll figure out a way to adapt downstream

drsooch commented 1 year ago

I honestly, don't think there is much to change. The TH generation seems sensible, I don't think there's much to change honestly. Codegen is pretty much straightforward, no matter what language you are using. I made some general code nit picks that honestly you can just ignore. There were one or two actual suggestions that I think are worth it. Otherwise lgtm.

drsooch commented 1 year ago

operators Also not sure why the operator-like constructors appear like this on my Haddock. It seems to just be for Record Fields

July541 commented 1 year ago

Any update here? I'm going to address some lsp-test parts, some new features from 3.16 spec attracted me.

michaelpj commented 1 year ago

I have a partially-rewritten version that generates Haskell source instead. I wasn't able to get this version to work with GHC 9, and the thought of trying to make it work with multiple GHC versions made me scared. So I decided to switch to generating source. I need to finish it, basically...

michaelpj commented 1 year ago

Closing in favour of https://github.com/haskell/lsp/pull/478