Skip to content

Conversation

soifou
Copy link
Collaborator

@soifou soifou commented Jul 31, 2025

This adds a new frecency config table with options to enable it, set the database path, and tweak locking.

It also deprecates the old boolean flags fuzzy.use_frecency and fuzzy.use_unsafe_no_lock, showing a heads-up notice when used.

fuzzy = {
  -- OLD
  use_frecency = true,
  use_unsafe_no_lock = false,

  -- NEW
  frecency = {
    enabled = true,
    unsafe_no_lock = false,
  }
}

If an old frecency database directory exists, it will be automatically migrated to the new configurable location, no manual steps needed.

Closes #2006


Some side notes:

  • The path in state could also be renamed to blink_cmp instead of blink/cmp. The first folder is always empty.
    - Currently, I use utils.notify instead of assert for soft notifications. In v2, I think we can either use assert or completely remove the reference.
  • Feel free to rephrase the notification/docs as you see fit.
  • While working on the PR, I noticed that the use_unsafe_no_lock setting used here:
    fuzzy.implementation.init_db(vim.fn.stdpath('data') .. '/blink/cmp/fuzzy.db', config.use_unsafe_no_lock)
    is incorrect. It should be config.fuzzy.use_unsafe_no_lock instead. Although, I guess it's not widely used by users.

@soifou soifou force-pushed the feat/fuzzy-frecency branch from fbfecd0 to fae55a0 Compare July 31, 2025 14:55
This adds a new frecency config table with options to enable it, set the
database path, and tweak locking.

It also deprecates the old boolean flags `fuzzy.use_frecency` and
`fuzzy.use_unsafe_no_lock`, showing a heads-up notice when used.

```lua
fuzzy = {
  -- OLD
  use_frecency = true,
  use_unsafe_no_lock = false,

  -- NEW
  frecency = {
    enabled = true,
    unsafe_no_lock = false,
  }
}
```

If an old frecency database directory exists, it will be automatically
migrated to the new configurable location, no manual steps needed.

Closes #2006
@soifou soifou force-pushed the feat/fuzzy-frecency branch from fae55a0 to a1504f7 Compare July 31, 2025 14:56
@Saghen
Copy link
Owner

Saghen commented Jul 31, 2025

Looks great! I think we should use vim.deprecate instead of notifying the user though, that way they can make the change at their leisure without getting a notification on launch.

is incorrect. It should be config.fuzzy.use_unsafe_no_lock instead. Although, I guess it's not widely used by users.

Hah I wonder if a single user has this enabled then. We should still keep it around for crazy lads like #817

@soifou
Copy link
Collaborator Author

soifou commented Jul 31, 2025

A minor issue is that since I removed the fields (to easily detect if the user still has them), it also displays the (non-blocking) message blink.cmp fuzzy → use_frecency Unexpected field in configuration! which runs before fuzzy.validate.

Ideally, we should distinguish a non-existent field from a deprecated field or you see a better way to handle this?

@Saghen
Copy link
Owner

Saghen commented Sep 2, 2025

Thanks! I've dropped the migration as I don't love the idea of doing synchronous IO on startup. The frecency database only stores up to 2 weeks so it shouldn't be a huge deal for users and it's nice to avoid that failure mode. If you feel like making it async is worth the effort though, I'd be open to it.

It looks like vim.deprecate results in a "press Enter" on startup, and only Nvim is special cased to store it in the healthchecks :( Not a huge deal though, I doubt many people have these options set.

The path in state could also be renamed to blink_cmp instead of blink/cmp. The first folder is always empty.

Fyi, the intention is that other blink projects will use the same folder such as blink.pairs or blink.pick

@Saghen Saghen merged commit b8154b4 into main Sep 2, 2025
6 checks passed
@Saghen Saghen deleted the feat/fuzzy-frecency branch September 2, 2025 14:47
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.

Open frecency db in stdpath('state') instead of 'data'
2 participants