2023-07-05 14:42:12 +02:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-07-05 14:42:12 +02:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.plugins.illuminate;
|
|
|
|
|
|
|
|
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
|
|
|
|
|
|
|
|
commonOptions = with helpers.defaultNullOpts; {
|
|
|
|
providers = mkListStr ''["lsp" "treesitter" "regex"]'' ''
|
|
|
|
Provider used to get references in the buffer, ordered by priority.
|
|
|
|
'';
|
|
|
|
|
|
|
|
delay = mkInt 100 ''
|
|
|
|
Delay in milliseconds.
|
|
|
|
'';
|
|
|
|
|
|
|
|
modesDenylist = mkListStr "[]" ''
|
|
|
|
Modes to not illuminate, this overrides `modes_allowlist`.
|
|
|
|
See `:help mode()` for possible values.
|
|
|
|
'';
|
|
|
|
|
|
|
|
modesAllowlist = mkListStr "[]" ''
|
2024-03-07 19:44:13 +01:00
|
|
|
Modes to illuminate, this is overridden by `modes_denylist`.
|
2023-07-05 14:42:12 +02:00
|
|
|
See `:help mode()` for possible values.
|
|
|
|
'';
|
|
|
|
|
|
|
|
providersRegexSyntaxDenylist = mkListStr "[]" ''
|
|
|
|
Syntax to not illuminate, this overrides `providers_regex_syntax_allowlist`.
|
|
|
|
Only applies to the 'regex' provider.
|
|
|
|
Use `:echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')`.
|
|
|
|
'';
|
|
|
|
|
|
|
|
providersRegexSyntaxAllowlist = mkListStr "[]" ''
|
2024-03-07 19:44:13 +01:00
|
|
|
Syntax to illuminate, this is overridden by `providers_regex_syntax_denylist`.
|
2023-07-05 14:42:12 +02:00
|
|
|
Only applies to the 'regex' provider.
|
|
|
|
Use `:echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')`.
|
|
|
|
'';
|
|
|
|
|
|
|
|
underCursor = mkBool true ''
|
|
|
|
Whether or not to illuminate under the cursor.
|
|
|
|
'';
|
|
|
|
|
|
|
|
largeFileCutoff = helpers.mkNullOrOption types.int ''
|
|
|
|
Number of lines at which to use `large_file_config`.
|
|
|
|
The `under_cursor` option is disabled when this cutoff is hit.
|
|
|
|
'';
|
|
|
|
|
|
|
|
minCountToHighlight = mkInt 1 ''
|
|
|
|
Minimum number of matches required to perform highlighting.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
filetypeOptions = {
|
|
|
|
filetypesDenylist = mkListStr ''["dirvish" "fugitive"]'' ''
|
|
|
|
Filetypes to not illuminate, this overrides `filetypes_allowlist`.
|
|
|
|
'';
|
|
|
|
|
|
|
|
filetypesAllowlist = mkListStr "[]" ''
|
2024-03-07 19:44:13 +01:00
|
|
|
Filetypes to illuminate, this is overridden by `filetypes_denylist`.
|
2023-07-05 14:42:12 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.plugins.illuminate =
|
|
|
|
with helpers;
|
|
|
|
with defaultNullOpts;
|
2024-01-25 16:15:55 +01:00
|
|
|
helpers.neovim-plugin.extraOptionsOptions
|
2023-07-05 14:42:12 +02:00
|
|
|
// {
|
|
|
|
enable = mkEnableOption "vim-illuminate";
|
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = mkPluginPackageOption "vim-illuminate" pkgs.vimPlugins.vim-illuminate;
|
2023-07-05 14:42:12 +02:00
|
|
|
|
2023-12-29 11:52:05 +01:00
|
|
|
filetypeOverrides =
|
|
|
|
helpers.defaultNullOpts.mkNullable
|
|
|
|
(
|
|
|
|
with types;
|
|
|
|
attrsOf (submodule {
|
|
|
|
options = commonOptions;
|
|
|
|
})
|
2024-05-05 19:39:35 +02:00
|
|
|
)
|
2023-12-29 11:52:05 +01:00
|
|
|
"{}"
|
|
|
|
''
|
|
|
|
Filetype specific overrides.
|
|
|
|
The keys are strings to represent the filetype.
|
|
|
|
'';
|
2023-07-05 14:42:12 +02:00
|
|
|
|
|
|
|
largeFileOverrides = mkOption {
|
|
|
|
type = types.submodule { options = commonOptions // filetypeOptions; };
|
|
|
|
description = ''
|
|
|
|
Config to use for large files (based on large_file_cutoff).
|
|
|
|
Supports the same keys passed to .configure
|
|
|
|
If null, illuminate will be disabled for large files.
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// commonOptions
|
|
|
|
// filetypeOptions;
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
filetypeSetupOptions =
|
|
|
|
filetypeOptions: with filetypeOptions; {
|
|
|
|
filetypes_denylist = filetypesDenylist;
|
|
|
|
filetypes_allowlist = filetypesAllowlist;
|
|
|
|
};
|
|
|
|
commonSetupOptions =
|
|
|
|
opts: with opts; {
|
|
|
|
inherit providers;
|
|
|
|
inherit delay;
|
|
|
|
modes_denylist = modesDenylist;
|
|
|
|
modes_allowlist = modesAllowlist;
|
|
|
|
providers_regex_syntax_denylist = providersRegexSyntaxDenylist;
|
|
|
|
providers_regex_syntax_allowlist = providersRegexSyntaxAllowlist;
|
|
|
|
under_cursor = underCursor;
|
|
|
|
large_file_cutoff = largeFileCutoff;
|
|
|
|
min_count_to_highlight = minCountToHighlight;
|
|
|
|
};
|
|
|
|
setupOptions =
|
|
|
|
with cfg;
|
|
|
|
{
|
|
|
|
large_file_overrides =
|
|
|
|
(commonSetupOptions largeFileOverrides) // (filetypeSetupOptions largeFileOverrides);
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-12-29 10:52:16 +01:00
|
|
|
filetype_overrides = helpers.ifNonNull' filetypeOverrides (
|
|
|
|
mapAttrs (_: commonSetupOptions) filetypeOverrides
|
|
|
|
);
|
2023-07-05 14:42:12 +02:00
|
|
|
}
|
|
|
|
// (filetypeSetupOptions cfg)
|
|
|
|
// (commonSetupOptions cfg);
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
|
|
|
|
extraConfigLua = ''
|
|
|
|
require("illuminate").configure(${helpers.toLuaObject setupOptions})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|