mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/improved-search: init
This commit is contained in:
parent
a88a282a11
commit
ad6a08b695
3 changed files with 173 additions and 0 deletions
|
@ -145,6 +145,7 @@
|
|||
./utils/harpoon.nix
|
||||
./utils/hop.nix
|
||||
./utils/illuminate.nix
|
||||
./utils/improved-search.nix
|
||||
./utils/indent-blankline.nix
|
||||
./utils/indent-o-matic.nix
|
||||
./utils/instant.nix
|
||||
|
|
123
plugins/utils/improved-search.nix
Normal file
123
plugins/utils/improved-search.nix
Normal file
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
# This plugin is only configured through keymaps, so we use `mkVimPlugin` without the
|
||||
# `globalPrefix` argument to avoid the creation of the `settings` option.
|
||||
helpers.vim-plugin.mkVimPlugin config {
|
||||
name = "improved-search";
|
||||
originalName = "improved-search.nvim";
|
||||
defaultPackage = pkgs.vimPlugins.improved-search-nvim;
|
||||
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
|
||||
extraOptions = {
|
||||
keymaps = mkOption {
|
||||
description = ''
|
||||
Keymap definitions for search functions
|
||||
|
||||
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
|
||||
'';
|
||||
type = with helpers.nixvimTypes;
|
||||
listOf (
|
||||
submodule {
|
||||
options = {
|
||||
key = mkOption {
|
||||
type = str;
|
||||
description = "The key to map.";
|
||||
example = "!";
|
||||
};
|
||||
|
||||
mode = helpers.keymaps.mkModeOption "";
|
||||
|
||||
action = mkOption {
|
||||
type = with helpers.nixvimTypes;
|
||||
maybeRaw (
|
||||
# https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators
|
||||
enum [
|
||||
"stable_next"
|
||||
"stable_previous"
|
||||
"current_word"
|
||||
"current_word_strict"
|
||||
"in_place"
|
||||
"in_place_strict"
|
||||
"forward"
|
||||
"forward_strict"
|
||||
"backward"
|
||||
"backward_strict"
|
||||
]
|
||||
);
|
||||
description = ''
|
||||
The action to execute.
|
||||
|
||||
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
|
||||
'';
|
||||
example = "in_place";
|
||||
};
|
||||
|
||||
options = helpers.keymaps.mapConfigOptions;
|
||||
};
|
||||
}
|
||||
);
|
||||
default = [];
|
||||
example = [
|
||||
{
|
||||
mode = ["n" "x" "o"];
|
||||
key = "n";
|
||||
action = "stable_next";
|
||||
}
|
||||
{
|
||||
mode = ["n" "x" "o"];
|
||||
key = "N";
|
||||
action = "stable_previous";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "!";
|
||||
action = "current_word";
|
||||
options.desc = "Search current word without moving";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "!";
|
||||
action = "in_place";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "*";
|
||||
action = "forward";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "#";
|
||||
action = "backward";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "|";
|
||||
action = "in_place";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
keymaps =
|
||||
map (
|
||||
keymap: {
|
||||
inherit (keymap) key options mode;
|
||||
action =
|
||||
if isString keymap.action
|
||||
# One of the plugin builtin functions
|
||||
then helpers.mkRaw "require('improved-search').${keymap.action}"
|
||||
# If the user specifies a raw action directly
|
||||
else keymap.action;
|
||||
}
|
||||
)
|
||||
cfg.keymaps;
|
||||
};
|
||||
}
|
49
tests/test-sources/plugins/utils/improved-search.nix
Normal file
49
tests/test-sources/plugins/utils/improved-search.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.improved-search.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.improved-search = {
|
||||
enable = true;
|
||||
|
||||
keymaps = [
|
||||
{
|
||||
mode = ["n" "x" "o"];
|
||||
key = "n";
|
||||
action = "stable_next";
|
||||
}
|
||||
{
|
||||
mode = ["n" "x" "o"];
|
||||
key = "N";
|
||||
action = "stable_previous";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "!";
|
||||
action = "current_word";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "!";
|
||||
action = "in_place";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "*";
|
||||
action = "forward";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "#";
|
||||
action = "backward";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "|";
|
||||
action = "in_place";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue