forked from niuiic/blink-cmp-rg.nvim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: complicated initialization of the toggling feature
Issue ===== Enabling the toggling feature requires a manual setup call. It's difficult to do in a clean way that avoids duplicating the config. Solution ======== Simplify the initialization and remove the ability to change the toggling configuration after the initial load. I think that's not a very useful feature anyway.
- Loading branch information
1 parent
e83155e
commit 61c7dcf
Showing
6 changed files
with
44 additions
and
36 deletions.
There are no files selected for viewing
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
8 changes: 0 additions & 8 deletions
8
integration-tests/test-environment/config-modifications/enable_toggling.lua
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local toggles = {} | ||
|
||
toggles.initialized = false | ||
|
||
---@param config blink-ripgrep.Options | ||
function toggles.init_once(config) | ||
if toggles.initialized then | ||
return | ||
end | ||
assert(config.future_features.toggles) | ||
|
||
local on_off = config.future_features.toggles.on_off | ||
if not on_off then | ||
return | ||
end | ||
|
||
require("snacks.toggle") | ||
.new({ | ||
id = "blink-ripgrep-manual-mode", | ||
name = "blink-ripgrep", | ||
get = function() | ||
return config.mode == "on" | ||
end, | ||
set = function(state) | ||
if state then | ||
config.mode = "on" | ||
else | ||
config.mode = "off" | ||
end | ||
end, | ||
}) | ||
:map(on_off, { mode = { "n" } }) | ||
toggles.initialized = true | ||
end | ||
|
||
return toggles |