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
pkgs, , config
config, , lib
lib, , ...
...
}: }:
with lib; { with lib; {
options.plugins.treesitter-refactor = let options.plugins.treesitter-refactor =
let
disable = mkOption { disable = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
description = "List of languages to disable the module on"; description = "List of languages to disable the module on";
}; };
in { in
{
enable = enable =
mkEnableOption mkEnableOption
"Enable treesitter-refactor (requires plugins.treesitter.enable to be true)"; "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 = { highlightDefinitions = {
inherit disable; inherit disable;
enable = enable =
@ -95,11 +103,13 @@ with lib; {
}; };
}; };
config = let config =
let
cfg = config.plugins.treesitter-refactor; cfg = config.plugins.treesitter-refactor;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-refactor]; extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.refactor = { plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = { highlight_definitions = {
inherit (cfg.highlightDefinitions) enable disable; inherit (cfg.highlightDefinitions) enable disable;
@ -112,9 +122,11 @@ with lib; {
}; };
navigation = { navigation = {
inherit (cfg.navigation) enable disable; inherit (cfg.navigation) enable disable;
keymaps = let keymaps =
let
cfgK = cfg.navigation.keymaps; cfgK = cfg.navigation.keymaps;
in { in
{
goto_definition = cfgK.gotoDefinition; goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback; goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons; list_definitions = cfgK.listDefinitons;