treesitter-refactor: package option + formatting

This commit is contained in:
Alexander Nortung 2023-01-17 21:50:22 +01:00
parent 4e116aad44
commit 7cd4a44462

View file

@ -1,20 +1,28 @@
{
pkgs,
config,
lib,
...
{ pkgs
, config
, lib
, ...
}:
with lib; {
options.plugins.treesitter-refactor = let
options.plugins.treesitter-refactor =
let
disable = mkOption {
type = types.listOf types.str;
default = [];
default = [ ];
description = "List of languages to disable the module on";
};
in {
in
{
enable =
mkEnableOption
"Enable treesitter-refactor (requires plugins.treesitter.enable to be true)";
package = mkOption {
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter-refactor;
description = "Plugin to use for treesitter-refactor";
};
highlightDefinitions = {
inherit disable;
enable =
@ -95,11 +103,13 @@ with lib; {
};
};
config = let
config =
let
cfg = config.plugins.treesitter-refactor;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-refactor];
extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = {
inherit (cfg.highlightDefinitions) enable disable;
@ -108,13 +118,15 @@ with lib; {
highlight_current_scope = cfg.highlightCurrentScope;
smart_rename = {
inherit (cfg.smartRename) enable disable;
keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
keymaps = { smart_rename = cfg.smartRename.keymaps.smartRename; };
};
navigation = {
inherit (cfg.navigation) enable disable;
keymaps = let
keymaps =
let
cfgK = cfg.navigation.keymaps;
in {
in
{
goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons;