-
-
Notifications
You must be signed in to change notification settings - Fork 390
Implement selection range request lsp feature #212
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
Comments
At first I was about to put this down as just a vscode thing but apparently it does use LSP? https://code.visualstudio.com/updates/v1_31#_smart-selections |
From what I understand, yes, it relies on LSP. Also, I think it makes sense, since it's really language-dependent to know what token spans are "bigger than/including" smaller token spans. E.g. a language/framework may use an opening bracket |
I'm wondering what specific LSP features it uses though, since as far as I'm aware there's no "smart selection" language feature in LSP. Perhaps it's using the semantic highlighting stuff? |
@bubba There is now, |
@Avi-D-coder nice! I think we should be able to implement this seeing as it just looks like a matter of dealing with the parsed ast. Perhaps we can add it at the ghcide level |
* First attempt at TH support * Update TcModuleResult when generating core * Be a bit more cautious when asking for bytecode * Check need for bytecode not only in source file itself, also in global information * Add a test (based on #212) * Fix test (thanks, @jinwoo) * Split GenerateCore and GenerateByteCode
@bubba what would have to be changed to implement this? i'm a big fan of this feature in every language i use. |
@alok and the link to rust code handling SelectionRange could be helpful to do the same here:
So we should analyze the ghc parsed ast and match the desired boundaries (based on delimiters ans significant whitespace) |
@jneira I'm new to this codebase and trying to implement this feature. If I understand it correctly, a new lsp handler should be added to |
@kokobd thanks for planning work in hls, i would say this is a core feature with one possible useful implementation which make sense to have in ghcide. But maybe it could be added to plugin methods too. |
I think it shouldn't be problematic to add an implementation of |
It would be nice to have a way to give an error from |
For this LSP feature, if the responses are not combinable, it probably doesn't make sense to build up an HLS Plugin infrastructure. Instead, just register an LSP handler directly in ghcide as done for other core features:
|
I don't see why not. We already have several non-combinable methods in there, notably the document formatting methods, which just take the first response from the list!
|
yeah but agree with @pepeiborra: if the feature only has one possible sensible implementation, it is better to hardcode it in ghcide itself, why do you think it would be better to place it in a plugin, code organization? |
To be clear, my suggestion for
Yeah, basically. I don't know that we have a hard and fast policy for what goes in plugins, but I'd been assuming we want to do as much as possible to stop growing |
Plugins do enable more gradual upgrades when a new GHC version is released. I have been working on upgrading the exactprint code actions for the last couple of weeks, and wishing they had been factored out of ghcide already |
There doesn't seem to be a sensible way to combine responses. But as different users might prefer different paces for the "expand selection" action, I think leaving a posibility to override the behavior in plugins is not bad.
|
I think that's fine for now. We can worry about the weird behaviour of |
Hi,
I started toying with the "Expand selection" (Alt + Shift + Right arrow by default on Linux) feature in VS Code and I noticed some quirks here and there. As usual, I am unsure if this is an HLS or Ghcide issue, sorry 😅
To reproduce:
When using "Expand selection" feature several times, here's what happens:
foo
foo = s -- start with your cursor on this line, somewhere on the foo field
foo = s -- start with your cursor on this line, somewhere on the foo field
(the left spaces are now included, but Github doesn't display them...)bar
(i.e. does not include the empty string case)IMHO 6 is weird, there should be additional steps:
Foo {}
expressionThe text was updated successfully, but these errors were encountered: