forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (LSP) suggest names that match any part of the current prefix (n…
…oir-lang#5752) # Description ## Problem Part of noir-lang#1577 ## Summary As I mentioned in noir-lang#5741, I noticed Rust Analyzer will suggests methods and names where the prefix you are writing matches any part of the name. Well, kind of, the logic is not exactly that, but that's what's implemented in this PR. It should make finding things much easier (if you are looking for stuff related to "merkle" or "hasher" you just need to type that). ![lsp-complete-any-part](https://github.com/user-attachments/assets/a65adc20-fc96-4682-b1c3-8961c434a133) It works in any context, for example struct fields: ![lsp-complete-any-part-struct-field](https://github.com/user-attachments/assets/f52193ef-adf7-493b-afa5-dbae9009857e) ## Additional Context None. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
6 changed files
with
114 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,33 +1,39 @@ | ||
/// Sort text for "new" methods: we want these to show up before anything else, | ||
/// if we are completing at something like `Foo::` | ||
pub(super) fn new_sort_text() -> String { | ||
"3".to_string() | ||
"a".to_string() | ||
} | ||
|
||
/// This is the default sort text. | ||
pub(super) fn default_sort_text() -> String { | ||
"5".to_string() | ||
"b".to_string() | ||
} | ||
|
||
/// We want crates and modules to show up after other things (for example | ||
/// local variables, functions or types) | ||
pub(super) fn crate_or_module_sort_text() -> String { | ||
"c".to_string() | ||
} | ||
|
||
/// Sort text for auto-import items. We want these to show up after local definitions. | ||
pub(super) fn auto_import_sort_text() -> String { | ||
"6".to_string() | ||
"d".to_string() | ||
} | ||
|
||
/// When completing something like `Foo::`, we want to show methods that take | ||
/// self after the other ones. | ||
pub(super) fn self_mismatch_sort_text() -> String { | ||
"7".to_string() | ||
"e".to_string() | ||
} | ||
|
||
/// We want to show operator methods last. | ||
pub(super) fn operator_sort_text() -> String { | ||
"8".to_string() | ||
"f".to_string() | ||
} | ||
|
||
/// If a name begins with underscore it's likely something that's meant to | ||
/// be private (but visibility doesn't exist everywhere yet, so for now | ||
/// we assume that) | ||
pub(super) fn underscore_sort_text() -> String { | ||
"9".to_string() | ||
"g".to_string() | ||
} |
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