haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

Native support for Happy's .y files and grammar language #4409

Open anka-213 opened 1 month ago

anka-213 commented 1 month ago

Is your enhancement request related to a problem? Please describe.

Independent of the Haskell part of a Happy grammar (issue #689), there is also the grammar itself which would be nice to get some basic language server support for (like go to definition) to make it easier to navigate large grammars.

In this code

InlinePragma :: { Pragma }
InlinePragma
  : '{-#' 'INLINE' PragmaQName '#-}'
    { InlinePragma (getRange ($1,$2,$3,$4)) True $3 }

I would like to be able to go to definition for PragmaQName.

Describe the solution you'd like

I'd like some very basic language support for Happy's .y grammar files themselves integrated into HLS.

Describe alternatives you've considered

Another option would be to implement this as a completely separate language server and extension, since it is a separate language from Haskell, but that might make it more difficult to integrate with the inline Haskell parts (as well as inhibit discoverability). But maybe HLS's current architecture would make it difficult to add a non-haskell language, so it would be easier to make it separate anyways?

Additional context

michaelpj commented 3 weeks ago

I think this is doable - we have the cabal plugin which works on non-Haskell files, so you should be able to have a similar architecture. Actually working out what things are might be tricky, though!