-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5182 from unisonweb/cp/improve-lsp-completion
- Loading branch information
Showing
10 changed files
with
181 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
unison-cli/src/Unison/Codebase/Editor/HandleInput/LSPDebug.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Unison.Codebase.Editor.HandleInput.LSPDebug (debugLspNameCompletion) where | ||
|
||
import Unison.Cli.Monad (Cli) | ||
import Unison.Cli.Monad qualified as Cli | ||
import Unison.Cli.NamesUtils qualified as Cli | ||
import Unison.Codebase.Editor.Output (Output (DisplayDebugLSPNameCompletions)) | ||
import Unison.LSP.Completion qualified as Completion | ||
import Unison.Prelude | ||
|
||
debugLspNameCompletion :: Text -> Cli () | ||
debugLspNameCompletion prefix = do | ||
names <- Cli.currentNames | ||
let ct = Completion.namesToCompletionTree names | ||
let (_, matches) = Completion.completionsForQuery ct prefix | ||
Cli.respond $ DisplayDebugLSPNameCompletions matches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
```ucm:hide | ||
scratch/main> builtins.merge lib.builtins | ||
``` | ||
|
||
```unison:hide | ||
foldMap = "top-level" | ||
nested.deeply.foldMap = "nested" | ||
lib.base.foldMap = "lib" | ||
lib.dep.lib.transitive.foldMap = "transitive-lib" | ||
-- A deeply nested definition with the same hash as the top level one. | ||
-- This should not be included in the completion results if a better name with the same hash IS included. | ||
lib.dep.lib.transitive_same_hash.foldMap = "top-level" | ||
foldMapWith = "partial match" | ||
other = "other" | ||
``` | ||
|
||
```ucm:hide | ||
scratch/main> add | ||
``` | ||
|
||
Completion should find all the `foldMap` definitions in the codebase, | ||
sorted by number of name segments, shortest first. | ||
|
||
Individual LSP clients may still handle sorting differently, e.g. doing a fuzzy match over returned results, or | ||
prioritizing exact matches over partial matches. We don't have any control over that. | ||
|
||
```ucm | ||
scratch/main> debug.lsp-name-completion foldMap | ||
``` | ||
|
||
Should still find the term which has a matching hash to a better name if the better name doesn't match. | ||
```ucm | ||
scratch/main> debug.lsp-name-completion transitive_same_hash.foldMap | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
```unison | ||
foldMap = "top-level" | ||
nested.deeply.foldMap = "nested" | ||
lib.base.foldMap = "lib" | ||
lib.dep.lib.transitive.foldMap = "transitive-lib" | ||
-- A deeply nested definition with the same hash as the top level one. | ||
-- This should not be included in the completion results if a better name with the same hash IS included. | ||
lib.dep.lib.transitive_same_hash.foldMap = "top-level" | ||
foldMapWith = "partial match" | ||
other = "other" | ||
``` | ||
|
||
Completion should find all the `foldMap` definitions in the codebase, | ||
sorted by number of name segments, shortest first. | ||
|
||
Individual LSP clients may still handle sorting differently, e.g. doing a fuzzy match over returned results, or | ||
prioritizing exact matches over partial matches. We don't have any control over that. | ||
|
||
```ucm | ||
scratch/main> debug.lsp-name-completion foldMap | ||
Matching Path Name Hash | ||
foldMap foldMap #o38ps8p4q6 | ||
foldMapWith foldMapWith #r9rs4mcb0m | ||
foldMap nested.deeply.foldMap #snrjegr5dk | ||
foldMap lib.base.foldMap #jf4buul17k | ||
foldMap lib.dep.lib.transitive.foldMap #0o01gvr3fi | ||
``` | ||
Should still find the term which has a matching hash to a better name if the better name doesn't match. | ||
```ucm | ||
scratch/main> debug.lsp-name-completion transitive_same_hash.foldMap | ||
Matching Path Name Hash | ||
transitive_same_hash.foldMap lib.dep.lib.transitive_same_hash.foldMap #o38ps8p4q6 | ||
``` |