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

feat: add fuzzy matching sorter experimentally #166

Merged
merged 9 commits into from
Apr 28, 2024
Merged

Conversation

delphinus
Copy link
Member

@delphinus delphinus commented Jan 15, 2024

Fix #165


This PR adds new sorters to match “fuzzily”.

telescope.setup {
  extensions = {
    frecency = {
      matcher = "fuzzy"  --> "default"|"fuzzy"
      scoring_function = function(recency, fzy_score)
        return (10 / (recency == 0 and 1 or recency)) - 1 / fzy_score
      end,
      -- ↑This is the default value.
    },
  },
}
  • default: use substr matcher. (default)
  • fuzzy: calculate ordering scores with recency scores and fuzzy matched ones.

fuzzy is the one you probably think it as “fuzzy”. The logic is from telescope.nvim's fzy logic (lua/telescope/algos/fzy.lua).

A newly added scoring_function will be used to customize the balance between recency scores and fzy ones.


Edited. I deleted fuzzy_full and add logic to calculate scores with recency scores and fzy scores.

@delphinus delphinus marked this pull request as ready for review April 28, 2024 08:36
@delphinus delphinus force-pushed the feat/fuzzy-match branch 3 times, most recently from a609367 to 73e4b97 Compare April 28, 2024 08:45
@delphinus delphinus force-pushed the feat/fuzzy-match branch 2 times, most recently from 80a3649 to 07f15ea Compare April 28, 2024 08:54
@delphinus delphinus merged commit 42b6421 into master Apr 28, 2024
16 checks passed
@delphinus delphinus deleted the feat/fuzzy-match branch April 28, 2024 08:58
@delphinus
Copy link
Member Author

It seems to work well in my dog-fooding. I merged this and it has closed #165, but feel free to reopen #165 and discuss again.

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.

[feature] Can we use both fuzzy matching & frecency scoring at the same time?
1 participant