From 3b9fa101fbb37774817a82db3e2721900786b43f Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 29 Dec 2023 10:52:16 +0100 Subject: [PATCH] plugins/illuminate: fix filetypeOverrides option --- plugins/utils/illuminate.nix | 30 +++++++------------ .../test-sources/plugins/utils/illuminate.nix | 15 ++++------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/plugins/utils/illuminate.nix b/plugins/utils/illuminate.nix index 607f97a9..c9655815 100644 --- a/plugins/utils/illuminate.nix +++ b/plugins/utils/illuminate.nix @@ -73,21 +73,10 @@ in { package = mkPackageOption "vim-illuminate" pkgs.vimPlugins.vim-illuminate; - filetypeOverrides = mkOption { - type = types.listOf (types.submodule { - options = { - filetype = defaultNullOpts.mkStr "" '' - Filetype to override - ''; - - overrides = commonOptions; - }; - }); - description = '' - Filetype specific overrides. - ''; - default = []; - }; + filetypeOverrides = helpers.defaultNullOpts.mkAttrsOf (types.submodule {options = commonOptions;}) "{}" '' + Filetype specific overrides. + The keys are strings to represent the filetype. + ''; largeFileOverrides = mkOption { type = types.submodule { @@ -126,10 +115,13 @@ in { { large_file_overrides = (commonSetupOptions largeFileOverrides) // (filetypeSetupOptions largeFileOverrides); - filetype_overrides = let - override = attr: {${attr.filetype} = commonSetupOptions attr.overrides;}; - in - map override filetypeOverrides; + filetype_overrides = + helpers.ifNonNull' filetypeOverrides + ( + mapAttrs + (_: commonSetupOptions) + filetypeOverrides + ); } // (filetypeSetupOptions cfg) // (commonSetupOptions cfg); diff --git a/tests/test-sources/plugins/utils/illuminate.nix b/tests/test-sources/plugins/utils/illuminate.nix index becc24b7..ce6a68ee 100644 --- a/tests/test-sources/plugins/utils/illuminate.nix +++ b/tests/test-sources/plugins/utils/illuminate.nix @@ -16,15 +16,12 @@ minCountToHighlight = 2; filetypesDenylist = ["csharp"]; filetypesAllowlist = ["python"]; - filetypeOverrides = [ - { - filetype = "c"; - overrides = { - delay = 10; - providers = ["treesitter"]; - }; - } - ]; + filetypeOverrides = { + x = { + delay = 10; + providers = ["treesitter"]; + }; + }; largeFileOverrides = { delay = 20; underCursor = true;