Skip to content

Commit

Permalink
refactor!(future): change backend configuration to use a table
Browse files Browse the repository at this point in the history
BREAKING CHANGE: If you were using the git_grep backend, you will need
to update your configuration to use the new format.

Issue
=====

It's possible to choose between different backends (ripgrep and gitgrep)
for the plugin. However, not all configuration options can be supported
for all backends. Right now there are many ripgrep specific options
that are confusing.

Solution
========

Change the backend configuration to use a table instead of a string.
Later on, we can add more configuration options for each backend.
  • Loading branch information
mikavilpas committed Feb 27, 2025
1 parent 73999e1 commit 35b6314
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require("blink-ripgrep").setup({
future_features = {
backend = "gitgrep",
backend = {
use = "gitgrep",
},
},
})
11 changes: 8 additions & 3 deletions lua/blink-ripgrep/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

---@class blink-ripgrep.FutureFeatures
---@field toggles? blink-ripgrep.ToggleKeymaps # Keymaps to toggle features on/off. This can be used to alter the behavior of the plugin without restarting Neovim. Nothing is enabled by default.
---@field backend? blink-ripgrep.BackendSelection # The backend to use for searching. Defaults to "ripgrep". "gitgrep" is available as a preview right now.
---@field backend? blink-ripgrep.BackendConfig

---@class blink-ripgrep.BackendConfig
---@field use? blink-ripgrep.BackendSelection # The backend to use for searching. Defaults to "ripgrep". "gitgrep" is available as a preview right now.

---@alias blink-ripgrep.BackendSelection
---| "ripgrep" # Use ripgrep (rg) for searching. Works in most cases.
Expand Down Expand Up @@ -58,7 +61,9 @@ RgSource.config = {
mode = "on",
future_features = {
toggles = nil,
backend = "ripgrep",
backend = {
use = "ripgrep",
},
},
}

Expand Down Expand Up @@ -108,7 +113,7 @@ function RgSource:get_completions(context, resolve)
---@type blink-ripgrep.Backend | nil
local backend
do
local be = (self.config.future_features or {}).backend
local be = (self.config.future_features or {}).backend.use

if be == "gitgrep" then
backend =
Expand Down

0 comments on commit 35b6314

Please sign in to comment.