haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Range Plugin: Add support for comments

Open sloorush opened this issue 3 years ago • 1 comments

  • closes #3005

This PR is supposed to add support for comments in the range plugin as they are not supported in HieAST, which the plugin is based upon. It uses Annotated ParsedSource to fetch comments and add them to the code range.

Status

I am currently trying to figure out how to get the comments out of the Annotated ParsedSource. I am currently trying to figure this out through Exact Print, but I am still not sure, Can someone please help?

cc: @kokobd @michaelpj

sloorush avatar Jul 22 '22 09:07 sloorush

How can I help? Feel free to contact me on IRC or Matrix if you have any questions. Meanwhile, I recommend adding folding range firstly, as it might be significantly easier than this.

kokobd avatar Jul 22 '22 14:07 kokobd

If you want help with the 9.2.1+ exactprint API, I can help. I haven't used the comments part of the AST yet myself, but the type of interest is https://hackage.haskell.org/package/ghc-9.4.2/docs/GHC-Parser-Annotation.html#t:EpaComment

santiweight avatar Oct 10 '22 17:10 santiweight

I tried to reserve comments while implementing hls-gadt-plugin, but it failed in some way I don't know. The comments seems can be attached to any semantic tokens.

I just complain it here, please let me know if you found a way to tidy comments, it will be a big improvement for hls-gadt-plugin.

July541 avatar Oct 11 '22 14:10 July541

if you found a way to tidy comments, it will be a big improvement for hls-gadt-plugin.

Have you tried using the balanceComments operation from ghc-exactprint? It can balance comments between two declarations. See the following talk:

https://youtu.be/GkoQbJofm1A?t=767

santiweight avatar Oct 11 '22 17:10 santiweight

Have you tried using the balanceComments operation from ghc-exactprint? It can balance comments between two declarations. See the following talk:

Don't remember the detail clearly, but it is worth trying next time :)

July541 avatar Oct 16 '22 11:10 July541