Skip to content
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

Improve label detail support in completions #2212

Merged
merged 5 commits into from
Apr 2, 2023
Merged

Conversation

ryuukk
Copy link
Contributor

@ryuukk ryuukk commented Feb 27, 2023

Before:

image

After:

image

Copy link
Member

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to be manually tested with various servers to ensure that it doesn't result in worse behavior in some cases.

I will do my share of testing, hopefully others will do theirs. :)

plugin/completion.py Outdated Show resolved Hide resolved
@@ -69,7 +69,7 @@ def format_completion(
annotation = lsp_label_description or lsp_detail
elif lsp_label.startswith(lsp_filter_text):
trigger = lsp_label
annotation = lsp_detail
annotation = lsp_label_description or lsp_detail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One datapoint from Pyright.

Before:

Screenshot 2023-03-04 at 22 44 01

After:

Screenshot 2023-03-04 at 22 39 32

I would say that it makes things better in this case too.

@rchl
Copy link
Member

rchl commented Mar 29, 2023

@jwortmann can you have a look since you were involved with related changes?

plugin/completion.py Outdated Show resolved Hide resolved
@jwortmann
Copy link
Member

jwortmann commented Mar 30, 2023

So if we prefer lsp_label_description (if set) for the annotation field here, we should probably do the same also in the else block below, right? That would be more consistent.

I think it depends on the server whether it is better or worse than using the lsp_detail. For pyright I would even find the "Auto-import" annotation more important, because those completions automatically add another import line at the top of the file, and this way I could avoid them more easily ;) (but I use "python.analysis.autoImportCompletions": false setting anyway).
So in general this will be a matter of preference too. But from my side it should be okay to merge it (after the two other points are resolved).

@rchl
Copy link
Member

rchl commented Mar 31, 2023

For pyright I would even find the "Auto-import" annotation more important, because those completions automatically add another import line at the top of the file, and this way I could avoid them more easily ;)

For this specific case I think it's much more preferred to see the name of the file/package in the completion list rather than just "auto-import" because, if you know the server a little bit, you know that seeing the name equals auto-import and so you still know that the auto-import will happen and at the same time you have much more information up-front.

@rchl
Copy link
Member

rchl commented Mar 31, 2023

So if we prefer lsp_label_description (if set) for the annotation field here, we should probably do the same also in the else block below, right? That would be more consistent.

Applied same logic to the else branch and also consolidated those two blocks. It's probably not easy to review.

Comment on lines 709 to 714
check(
resolve_support=False,
expected_regex=r"^f\(X& x\) \| does things$",
expected_regex=r"^f\(X& x\)$",
label="f",
label_details={"detail": "(X& x)", "description": "does things"}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those test are poor-mans version of the new ones so it would possibly be OK to remove those and convert to the new ones, if those test anything extra.

I say "poor-mans" version because those ignore "annotation" for example.

@jwortmann
Copy link
Member

For this specific case I think it's much more preferred to see the name of the file/package in the completion list rather than just "auto-import" because, if you know the server a little bit, you know that seeing the name equals auto-import and so you still know that the auto-import will happen and at the same time you have much more information up-front.

Yeah okay, I kind of agree, but this is only a valid assumption if this LSP server is the only source of completions which use the annotation field.

@rchl
Copy link
Member

rchl commented Apr 2, 2023

Yeah okay, I kind of agree, but this is only a valid assumption if this LSP server is the only source of completions which use the annotation field.

Yes, but that's intentional since we can't implement things the way spec intended due to ST limitations so we have to use heuristics or optimize for specific cases.

@rchl rchl changed the title Improve label detail support Improve label detail support in completions Apr 2, 2023
@rchl rchl merged commit ceb9309 into sublimelsp:main Apr 2, 2023
rchl added a commit that referenced this pull request Apr 17, 2023
* main:
  Clear pull diagnostics on file closed (#2224)
  html-escape diagnostic-related strings (#2228)
  Allow style overrides for inlay_hints.css (#2232)
  Fix exception for null response id (#2233)
  Add "outline" as an option for "document_highlight_style" (#2234)
  remove accidentally committed files
  Improve label detail support in completions (#2212)
  Update clojure-lsp docs (#2226)
  Add support for pull diagnostics (#2221)
  update test MockManager after API change
  add a client option for hiding non-project diagnostics (#2218)
  Fix some features might not work with dynamical registration (#2222)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants