ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
412 stars 154 forks source link

Better Completion for ExternalAutocomplete functions #1178

Closed Tangent-90 closed 11 months ago

Tangent-90 commented 11 months ago

WHAT

πŸ€– Generated by Copilot at b053be9

This pull request adds a new feature to the F# language server, which allows the user to configure how completion items for external symbols are displayed. It also improves the completion items for hash directives and keywords, and adds tests for the new feature. The main files affected are src/FsAutoComplete.Core/KeywordList.fs, src/FsAutoComplete/LspHelpers.fs, src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs, and test/FsAutoComplete.Tests.Lsp/CompletionTests.fs.

πŸ€– Generated by Copilot at b053be9

FullNameExternal Option for completion items Autumn of symbols

πŸ§‘β€πŸ’»πŸ”§πŸ§ͺ

WHY

  1. Try fix insert "Array.map" become "Array.map"

Before: GIF 2023-10-18 23-07-09

After: GIF 2023-10-18 23-05-58

  1. Fix completions with same label have same description

Before: GIF 2023-10-19 22-04-52

After: GIF 2023-10-19 22-08-33

  1. Add FullNameExternalAutocomplete

Before: GIF 2023-10-18 23-01-10

With FullNameExternalAutocomplete: GIF 2023-10-18 22-59-03

GIF 2023-10-19 22-09-38

HOW

πŸ€– Generated by Copilot at b053be9

Tangent-90 commented 11 months ago

There's two ways to display conpletions label, one is like "AA.BB.CC" and another is "CC (AA.BB)". Image_1697796857902.png

Image_1697796867566.png

When the full name is long, comparing to the second display way, the first one seems to be too messy, and can't quickly distinguish member's name.

Image_1697796804752.png

Image_1697796812164.png

So completions label is decided to display like "CC (AA.BB)".

To enter part of the full name to filter completion items, the filter text must contain its full name "AA.BB.CC".

As completions member name was the first part of the label, to make it first filter out by member name, and to make filtered label highlighted correctly by editors, the name must to be the first part of the filter text.

As the result, the format of filter text is member name + full name, which is "CCAA.BB.CC".

baronfel commented 11 months ago

Thanks @Tangent-90 - that helps me understand the intent quite a bit more!

baronfel commented 11 months ago

Pushed a tiny change to add more to the docs so it was clearer to me personally, but otherwise this LGTM and let's ship it! Ideally we could also add the option to the Ionide package.json so that end users have some docs for it.