2023-03-17 12:15:33 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
2023-03-17 12:15:33 +01:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
2023-11-06 15:04:08 +01:00
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
{
|
2023-03-17 12:15:33 +01:00
|
|
|
options.plugins.inc-rename = {
|
|
|
|
enable = mkEnableOption "inc-rename, a plugin previewing LSP renaming";
|
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "inc-rename" pkgs.vimPlugins.inc-rename-nvim;
|
2023-03-17 12:15:33 +01:00
|
|
|
|
|
|
|
cmdName = helpers.defaultNullOpts.mkStr "IncRename" "the name of the command";
|
2023-03-25 10:17:48 +01:00
|
|
|
|
2023-03-17 12:15:33 +01:00
|
|
|
hlGroup = helpers.defaultNullOpts.mkStr "Substitute" "the highlight group used for highlighting the identifier's new name";
|
2023-03-25 10:17:48 +01:00
|
|
|
|
2023-03-17 12:15:33 +01:00
|
|
|
previewEmptyName = helpers.defaultNullOpts.mkBool false ''
|
|
|
|
whether an empty new name should be previewed; if false the command preview will be cancelled
|
|
|
|
instead
|
|
|
|
'';
|
2023-03-25 10:17:48 +01:00
|
|
|
|
2023-03-17 12:15:33 +01:00
|
|
|
showMessage = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
whether to display a `Renamed m instances in n files` message after a rename operation
|
|
|
|
'';
|
2023-03-25 10:17:48 +01:00
|
|
|
|
2024-06-02 02:58:20 +01:00
|
|
|
inputBufferType = helpers.defaultNullOpts.mkNullable (types.enum [ "dressing" ]) null ''
|
2023-03-17 12:15:33 +01:00
|
|
|
the type of the external input buffer to use
|
|
|
|
'';
|
2023-03-25 10:17:48 +01:00
|
|
|
|
2024-06-02 02:58:20 +01:00
|
|
|
postHook = helpers.defaultNullOpts.mkLuaFn null ''
|
2023-03-17 12:15:33 +01:00
|
|
|
callback to run after renaming, receives the result table (from LSP handler) as an argument
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.plugins.inc-rename;
|
|
|
|
setupOptions = {
|
|
|
|
cmd_name = cfg.cmdName;
|
|
|
|
hl_group = cfg.hlGroup;
|
|
|
|
preview_empty_name = cfg.previewEmptyName;
|
|
|
|
show_message = cfg.showMessage;
|
|
|
|
input_buffer_type = cfg.inputBufferType;
|
2023-12-29 15:24:42 +01:00
|
|
|
post_hook = cfg.postHook;
|
2023-03-17 12:15:33 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
|
|
|
|
extraConfigLua = ''
|
|
|
|
require("inc_rename").setup(${helpers.toLuaObject setupOptions})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|