2023-10-13 22:47:44 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
2023-10-13 22:47:44 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
2024-12-22 09:58:27 +00:00
|
|
|
lib.nixvim.plugins.mkNeovimPlugin {
|
2024-07-23 00:01:09 +02:00
|
|
|
name = "better-escape";
|
2024-12-13 08:27:14 -06:00
|
|
|
packPathName = "better-escape.nvim";
|
2024-12-13 08:28:39 -06:00
|
|
|
moduleName = "better_escape";
|
2024-09-02 14:05:11 +01:00
|
|
|
package = "better-escape-nvim";
|
2023-10-13 22:47:44 +01:00
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
maintainers = [ maintainers.GaetanLepage ];
|
2023-10-13 22:47:44 +01:00
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
# TODO: introduced 2024-07-23. Remove after 24.11 release.
|
|
|
|
deprecateExtraOptions = true;
|
|
|
|
optionsRenamedToSettings = [ "timeout" ];
|
|
|
|
imports =
|
|
|
|
let
|
|
|
|
basePluginPath = [
|
|
|
|
"plugins"
|
|
|
|
"better-escape"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
[
|
|
|
|
(mkRemovedOptionModule (basePluginPath ++ [ "clearEmptyLines" ]) ''
|
|
|
|
This option has been removed upstream.
|
|
|
|
See the [upstream README](https://github.com/max397574/better-escape.nvim?tab=readme-ov-file#rewrite) for additional information.
|
|
|
|
'')
|
|
|
|
(mkRemovedOptionModule (basePluginPath ++ [ "keys" ]) ''
|
|
|
|
This option has been removed upstream.
|
|
|
|
See the [upstream README](https://github.com/max397574/better-escape.nvim?tab=readme-ov-file#rewrite) for additional information.
|
|
|
|
'')
|
|
|
|
(mkRemovedOptionModule (basePluginPath ++ [ "mapping" ]) ''
|
|
|
|
This option has been removed in favor of `plugins.better-escape.settings.mapping`.
|
|
|
|
See the [upstream README](https://github.com/max397574/better-escape.nvim?tab=readme-ov-file#rewrite) for additional information.
|
|
|
|
'')
|
|
|
|
];
|
2023-10-13 22:47:44 +01:00
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
settingsOptions = {
|
2024-01-02 00:30:10 +01:00
|
|
|
timeout = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.timeoutlen" ''
|
2023-10-13 22:47:44 +01:00
|
|
|
The time in which the keys must be hit in ms.
|
|
|
|
Uses the value of `vim.o.timeoutlen` (`options.timeoutlen` in nixvim) by default.
|
|
|
|
'';
|
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
default_mappings = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Whether to enable default key mappings.
|
2023-10-13 22:47:44 +01:00
|
|
|
'';
|
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
mappings = helpers.defaultNullOpts.mkAttrsOf' {
|
|
|
|
type = types.anything;
|
|
|
|
pluginDefault = {
|
|
|
|
i.j = {
|
|
|
|
k = "<Esc>";
|
|
|
|
j = "<Esc>";
|
|
|
|
};
|
|
|
|
c.j = {
|
|
|
|
k = "<Esc>";
|
|
|
|
j = "<Esc>";
|
|
|
|
};
|
|
|
|
t.j = {
|
|
|
|
k = "<Esc>";
|
|
|
|
j = "<Esc>";
|
|
|
|
};
|
|
|
|
v.j.k = "<Esc>";
|
|
|
|
s.j.k = "<Esc>";
|
|
|
|
};
|
|
|
|
example.i." "."<tab>".__raw = ''
|
|
|
|
function()
|
|
|
|
-- Defer execution to avoid side-effects
|
|
|
|
vim.defer_fn(function()
|
|
|
|
-- set undo point
|
|
|
|
vim.o.ul = vim.o.ul
|
|
|
|
require("luasnip").expand_or_jump()
|
|
|
|
end, 1)
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
description = "Define mappings for each mode.";
|
|
|
|
};
|
2023-10-13 22:47:44 +01:00
|
|
|
};
|
|
|
|
|
2024-07-23 00:01:09 +02:00
|
|
|
settingsExample = {
|
|
|
|
timeout = "vim.o.timeoutlen";
|
|
|
|
mapping = {
|
|
|
|
i." "."<tab>".__raw = ''
|
|
|
|
function()
|
|
|
|
-- Defer execution to avoid side-effects
|
|
|
|
vim.defer_fn(function()
|
|
|
|
-- set undo point
|
|
|
|
vim.o.ul = vim.o.ul
|
|
|
|
require("luasnip").expand_or_jump()
|
|
|
|
end, 1)
|
|
|
|
end
|
2023-10-13 22:47:44 +01:00
|
|
|
'';
|
|
|
|
};
|
2024-07-23 00:01:09 +02:00
|
|
|
};
|
2023-10-13 22:47:44 +01:00
|
|
|
}
|