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

Allow customization of mini.starter query #1338

Open
2 tasks done
jason0x43 opened this issue Nov 14, 2024 · 4 comments
Open
2 tasks done

Allow customization of mini.starter query #1338

jason0x43 opened this issue Nov 14, 2024 · 4 comments
Labels
feature-request Request for a feature to existing module mini.starter

Comments

@jason0x43
Copy link

Contributing guidelines

Module(s)

mini.starter

Description

Mini.starter intentionally doesn't support fuzzy finding. However, allowing users to provide an "is item active" function would allow users to modify the query process themselves to add fuzzy-like functionality without impacting the design of starter. Is this a feature that might be considered?

A simple implementation would just be to allow starter's config to accept an is_item_active property that, when set, would override H.is_item_active.

@jason0x43 jason0x43 added the feature-request Request for a feature to existing module label Nov 14, 2024
@echasnovski
Copy link
Owner

Thanks for the suggestion!

I'd rather have something like config.item_match to be a function(item, query) which returns true / false. At first glance seems reasonable, I'll take a look.

@jason0x43
Copy link
Author

For what it's worth, after experimenting with a couple different implementations, this is what I'm currently using:

// plugin config
starter.setup({
  ...
  item_is_active = function(item, query)
    return item.name:lower().find(query:lower()) ~= nil and item.action ~= ''
  end
});
// starter.lua
H.make_query = function(buf_id, query, echo_msg)
  local item_is_active = MiniStarter.config.item_is_active or H.item_is_active

  // replace H.item_is_active calls with item_is_active
end

@echasnovski
Copy link
Owner

There is also a vim.fn.matchfuzzy() function which can be used for a truly fuzzy matching.

@jason0x43
Copy link
Author

Nice, I wasn't aware of that one. It seems like it would require a bit more refactoring, though, since it works over the whole list rather than with a single item.

For my own use I'm not so concerned with fuzzy matching as just not always matching from the beginning of an item, because the part of a file name or path that really stands out (to me) may not always be at the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a feature to existing module mini.starter
Projects
None yet
Development

No branches or pull requests

2 participants