-
Notifications
You must be signed in to change notification settings - Fork 337
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
improvement: Use inlay hints for worksheets #6827
base: main
Are you sure you want to change the base?
Conversation
5e92f76
to
b311f11
Compare
@ckipp01 do you know if inlay hints would work ok for nvim-metals? I want to remove as many custom extensions as I can since we get more and more editors and implementing those custom extension might be too much of a hassle. |
8084e55
to
4994a1f
Compare
Yup, inlay hints are supported in nvim, so this should work. If I get a bit of time I'll try this pr out with nvim-metals and see if I hit on any issues. |
Thanks! I think I mostly need to fix tests here. I will also see how Zed handles it since I managed to get that set up for myself. |
I did some test on
There is one thing should be mentioned. Using inlay hints also means disabling editor's inlay hints feature will cause results not showing. Example configs are:
|
Looks like maybe it's because of lacking inlayHints/refresh ? Does neovim support that? |
Sure, but it's enabled by default (at least in VS Code) and other editor users might be sued to turning things on. We need to write about it in the release notes for sure. |
2180ce1
to
00e1925
Compare
Advantages: - this would allow us to stop using a custom extension and support more editors such as Zed - can reuse any new feature inlay hints add - reevaluate on change? (or should we remove it?) Disadvantages: - no way to set color - could mix with normal decorations TODO: - [ ] gather feedback - [ ] fix tests - [ ] check if we can remove other ways of publishing altogether
fb1cc3d
to
476256a
Compare
476256a
to
ec2a1b6
Compare
ec2a1b6
to
d60c695
Compare
d60c695
to
1f0aa91
Compare
"as a inlay hint at the end of the line." -> | ||
"hover on the inlay hint to expand it." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't it be more editors than only vscode
that support inline hints? Also aren't worksheet decorations using comments not supported after this PR?
getLabelParts(inlayHint).zip(parseData(data)) | ||
Option(inlayHint.getData()) match { | ||
case Some(data: JsonArray) => | ||
resolve( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move resolve
to try?
.map(_.map(_.toLsp())) | ||
.map( | ||
_.orElse { | ||
val path = params.textDocument.getUri.toAbsolutePath | ||
if (path.isWorksheet) | ||
worksheetProvider.hover(path, params.getPosition) | ||
else | ||
None | ||
}.orNull | ||
_.orNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map(_.map(_.toLsp()).orNull)
@@ -1016,7 +997,11 @@ abstract class MetalsLspService( | |||
if (userConfig.areSyntheticsEnabled()) | |||
compilers.inlayHints(params, token) | |||
else Future.successful(List.empty[l.InlayHint].asJava) | |||
} yield hints | |||
worksheet <- worksheetProvider.inlayHints( | |||
params.getTextDocument().getUri().toAbsolutePath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.getTextDocument().getUri().toAbsolutePath, | |
params.getTextDocument().getUri().toAbsolutePathSafe, |
distance.toRevised(statEnd) match { | ||
case Left(_) => | ||
case Right(right) => | ||
statEnd.setLine(right.startLine) | ||
statEnd.setCharacter(right.startColumn) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
distance.toRevised(statEnd) match { | |
case Left(_) => | |
case Right(right) => | |
statEnd.setLine(right.startLine) | |
statEnd.setCharacter(right.startColumn) | |
} | |
distance.toRevised(statEnd).foreach { right => | |
statEnd.setLine(right.startLine) | |
statEnd.setCharacter(right.startColumn) | |
} |
_ = client.onWorkDoneProgressStart = (_, _) => {} | ||
_ <- cancelled.future.withTimeout(10.seconds) | ||
_ = client.onWorkDoneProgressStart = (message, _) => { | ||
scribe.info(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@@ -266,6 +208,7 @@ abstract class BaseWorksheetLspSuite( | |||
cleanWorkspace() | |||
val cancelled = Promise[Unit]() | |||
client.onWorkDoneProgressStart = { (message, cancelParams) => | |||
scribe.info(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Advantages:
Disadvantages:
I plan on removing decoration protocol and worksheet fallback in this PR
TODO