2023-03-09 22:00:04 -05:00
|
|
|
{
|
2023-11-06 15:04:08 +01:00
|
|
|
lib,
|
|
|
|
helpers,
|
2023-03-09 22:00:04 -05:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.plugins.todo-comments;
|
2023-03-12 11:49:41 +01:00
|
|
|
|
|
|
|
commands = {
|
|
|
|
todoQuickFix = "TodoQuickFix";
|
|
|
|
todoLocList = "TodoLocList";
|
|
|
|
todoTrouble = "TodoTrouble";
|
|
|
|
todoTelescope = "TodoTelescope";
|
|
|
|
};
|
2023-03-09 22:00:04 -05:00
|
|
|
in
|
|
|
|
{
|
2023-11-06 15:53:26 +01:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [
|
|
|
|
"plugins"
|
|
|
|
"todo-comments"
|
|
|
|
"keymapsSilent"
|
|
|
|
] "Use `plugins.todo-comments.keymaps.<COMMAND>.options.silent`.")
|
|
|
|
];
|
2023-03-09 22:00:04 -05:00
|
|
|
options = {
|
2024-01-25 16:15:55 +01:00
|
|
|
plugins.todo-comments = helpers.neovim-plugin.extraOptionsOptions // {
|
2023-10-09 07:58:51 -05:00
|
|
|
enable = mkEnableOption "todo-comments";
|
2024-03-06 12:48:15 -08:00
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "todo-comments" pkgs.vimPlugins.todo-comments-nvim;
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2024-05-17 14:39:55 +02:00
|
|
|
ripgrepPackage = helpers.mkPackageOption {
|
2023-03-09 22:00:04 -05:00
|
|
|
default = pkgs.ripgrep;
|
|
|
|
description = "Which package (if any) to be added for file search support in todo-comments.";
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
signs = helpers.defaultNullOpts.mkBool true "Show icons in the signs column.";
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
signPriority = helpers.defaultNullOpts.mkInt 8 "Sign priority.";
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
keywords =
|
|
|
|
helpers.mkNullOrOption
|
|
|
|
(types.attrsOf (
|
|
|
|
types.submodule {
|
|
|
|
options = {
|
|
|
|
icon = helpers.mkNullOrOption types.str ''
|
|
|
|
Icon used for the sign, and in search results.
|
2023-03-09 22:00:04 -05:00
|
|
|
'';
|
2023-03-12 11:49:41 +01:00
|
|
|
|
|
|
|
color = helpers.mkNullOrOption types.str ''
|
|
|
|
Can be a hex color, or a named color.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
alt = helpers.mkNullOrOption (types.listOf types.str) ''
|
|
|
|
A set of other keywords that all map to this FIX keywords.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
signs = helpers.mkNullOrOption types.bool ''
|
|
|
|
Configure signs for some keywords individually.
|
2023-03-09 22:00:04 -05:00
|
|
|
'';
|
|
|
|
};
|
2023-03-12 11:49:41 +01:00
|
|
|
}
|
|
|
|
))
|
|
|
|
''
|
|
|
|
Configurations for keywords to be recognized as todo comments.
|
|
|
|
|
|
|
|
Default:
|
2023-08-07 13:18:01 +03:30
|
|
|
```nix
|
2023-03-12 11:49:41 +01:00
|
|
|
{
|
|
|
|
FIX = {
|
|
|
|
icon = " "; # Icon used for the sign, and in search results.
|
|
|
|
color = "error"; # Can be a hex color, or a named color.
|
|
|
|
alt = [ "FIXME" "BUG" "FIXIT" "ISSUE" ]; # A set of other keywords that all map to this FIX keywords.
|
|
|
|
};
|
|
|
|
TODO = { icon = " "; color = "info"; };
|
|
|
|
HACK = { icon = " "; color = "warning"; };
|
|
|
|
WARN = { icon = " "; color = "warning"; alt = [ "WARNING" "XXX" ]; };
|
|
|
|
PERF = { icon = " "; alt = [ "OPTIM" "PERFORMANCE" "OPTIMIZE" ]; };
|
|
|
|
NOTE = { icon = " "; color = "hint"; alt = [ "INFO" ]; };
|
|
|
|
TEST = { icon = "⏲ "; color = "test"; alt = [ "TESTING" "PASSED" "FAILED" ]; };
|
|
|
|
};
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
|
2023-12-09 23:09:50 +01:00
|
|
|
guiStyle = {
|
2023-03-12 11:49:41 +01:00
|
|
|
fg = helpers.defaultNullOpts.mkStr "NONE" ''
|
|
|
|
The gui style to use for the fg highlight group.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
|
|
|
bg = helpers.defaultNullOpts.mkStr "BOLD" ''
|
|
|
|
The gui style to use for the bg highlight group.
|
|
|
|
'';
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
mergeKeywords = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
When true, custom keywords will be merged with the default
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-12-09 23:09:50 +01:00
|
|
|
highlight = {
|
2023-03-12 11:49:41 +01:00
|
|
|
multiline = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Enable multiline todo comments.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
multilinePattern = helpers.defaultNullOpts.mkStr "^." ''
|
|
|
|
Lua pattern to match the next multiline from the start of the
|
|
|
|
matched keyword.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
multilineContext = helpers.defaultNullOpts.mkInt 10 ''
|
|
|
|
Extra lines that will be re-evaluated when changing a line.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
before = helpers.defaultNullOpts.mkStr "" ''
|
|
|
|
"fg" or "bg" or empty.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 17:55:09 +01:00
|
|
|
keyword = helpers.defaultNullOpts.mkStr "wide" ''
|
2023-03-12 11:49:41 +01:00
|
|
|
"fg", "bg", "wide", "wide_bg", "wide_fg" or empty.
|
|
|
|
(wide and wide_bg is the same as bg, but will also highlight
|
|
|
|
surrounding characters, wide_fg acts accordingly but with fg).
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
after = helpers.defaultNullOpts.mkStr "fg" ''
|
|
|
|
"fg" or "bg" or empty.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 17:55:09 +01:00
|
|
|
pattern =
|
|
|
|
helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) ".*<(KEYWORDS)\\s*:"
|
|
|
|
''
|
|
|
|
Pattern or list of patterns, used for highlighting (vim regex)
|
|
|
|
|
|
|
|
Note: the provided pattern will be embedded as such: `[[PATTERN]]`.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
commentsOnly = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
Uses treesitter to match keywords in comments only.
|
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
|
|
|
|
maxLineLen = helpers.defaultNullOpts.mkInt 400 ''
|
|
|
|
Ignore lines longer than this.
|
|
|
|
'';
|
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
exclude = helpers.mkNullOrOption (types.listOf types.str) ''
|
|
|
|
List of file types to exclude highlighting.
|
|
|
|
'';
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-03-12 11:49:41 +01:00
|
|
|
|
|
|
|
colors = helpers.mkNullOrOption (types.attrsOf (types.listOf types.str)) ''
|
|
|
|
List of named colors where we try to extract the guifg from the list
|
|
|
|
of highlight groups or use the hex color if hl not found as a fallback.
|
2024-05-05 19:39:35 +02:00
|
|
|
|
|
|
|
Default:
|
|
|
|
```nix
|
|
|
|
{
|
2023-03-12 11:49:41 +01:00
|
|
|
error = [ "DiagnosticError" "ErrorMsg" "#DC2626" ];
|
|
|
|
warning = [ "DiagnosticWarn" "WarningMsg" "#FBBF24" ];
|
|
|
|
info = [ "DiagnosticInfo" "#2563EB" ];
|
|
|
|
hint = [ "DiagnosticHint" "#10B981" ];
|
|
|
|
default = [ "Identifier" "#7C3AED" ];
|
2023-03-09 22:00:04 -05:00
|
|
|
test = [ "Identifier" "#FF00FF" ];
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
|
|
|
```
|
|
|
|
'';
|
2023-03-12 11:49:41 +01:00
|
|
|
|
2023-12-09 23:09:50 +01:00
|
|
|
search = {
|
2023-03-12 11:49:41 +01:00
|
|
|
command = helpers.defaultNullOpts.mkStr "rg" "Command to use for searching for keywords.";
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
args = helpers.mkNullOrOption (types.listOf types.str) ''
|
2024-03-06 12:48:15 -08:00
|
|
|
Arguments to use for the search command in list form.
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-03-12 11:49:41 +01:00
|
|
|
Default:
|
2023-08-07 13:18:01 +03:30
|
|
|
```nix
|
2023-03-12 11:49:41 +01:00
|
|
|
[
|
|
|
|
"--color=never"
|
|
|
|
"--no-heading"
|
|
|
|
"--with-filename"
|
|
|
|
"--line-number"
|
|
|
|
"--column"
|
|
|
|
];
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
|
2023-03-12 17:55:09 +01:00
|
|
|
pattern = helpers.defaultNullOpts.mkStr "\\b(KEYWORDS):" ''
|
2023-03-12 11:49:41 +01:00
|
|
|
Regex that will be used to match keywords.
|
|
|
|
Don't replace the (KEYWORDS) placeholder.
|
2023-03-12 17:55:09 +01:00
|
|
|
|
|
|
|
Note: the provided pattern will be embedded as such: `[[PATTERN]]`.
|
2023-03-12 11:49:41 +01:00
|
|
|
'';
|
2023-03-09 22:00:04 -05:00
|
|
|
};
|
2023-03-12 11:49:41 +01:00
|
|
|
|
|
|
|
keymaps =
|
|
|
|
let
|
|
|
|
mkKeymapOption =
|
|
|
|
optionName: funcName:
|
2023-11-06 15:53:26 +01:00
|
|
|
helpers.mkCompositeOption "Keymap settings for the `:${funcName}` function." {
|
2023-03-12 11:49:41 +01:00
|
|
|
key = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Key for the `${funcName}` function.";
|
|
|
|
};
|
|
|
|
|
|
|
|
cwd = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "Specify the directory to search for comments";
|
|
|
|
default = null;
|
|
|
|
example = "~/projects/foobar";
|
|
|
|
};
|
|
|
|
|
|
|
|
keywords = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = ''
|
|
|
|
Comma separated list of keywords to filter results by.
|
|
|
|
Keywords are case-sensitive.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
example = "TODO,FIX";
|
|
|
|
};
|
2023-11-06 15:53:26 +01:00
|
|
|
|
|
|
|
options = helpers.keymaps.mapConfigOptions;
|
2023-03-12 11:49:41 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
mapAttrs mkKeymapOption commands;
|
2023-03-09 22:00:04 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
setupOptions = {
|
2023-05-22 15:45:47 +05:30
|
|
|
inherit (cfg) signs;
|
2023-03-12 11:49:41 +01:00
|
|
|
sign_priority = cfg.signPriority;
|
2023-05-22 15:45:47 +05:30
|
|
|
inherit (cfg) keywords;
|
2023-03-12 11:49:41 +01:00
|
|
|
gui_style = cfg.guiStyle;
|
|
|
|
merge_keywords = cfg.mergeKeywords;
|
2023-12-09 23:09:50 +01:00
|
|
|
highlight = {
|
2023-03-12 11:49:41 +01:00
|
|
|
inherit (cfg.highlight)
|
|
|
|
multiline
|
|
|
|
before
|
|
|
|
keyword
|
|
|
|
after
|
|
|
|
exclude
|
|
|
|
;
|
2023-03-12 17:55:09 +01:00
|
|
|
pattern = helpers.ifNonNull' cfg.highlight.pattern (helpers.mkRaw "[[${cfg.highlight.pattern}]]");
|
2023-03-12 11:49:41 +01:00
|
|
|
multiline_pattern = cfg.highlight.multilinePattern;
|
|
|
|
multiline_context = cfg.highlight.multilineContext;
|
|
|
|
comments_only = cfg.highlight.commentsOnly;
|
|
|
|
max_line_len = cfg.highlight.maxLineLen;
|
|
|
|
};
|
2023-05-22 15:45:47 +05:30
|
|
|
inherit (cfg) colors;
|
2023-12-09 23:09:50 +01:00
|
|
|
search = {
|
2023-03-12 17:55:09 +01:00
|
|
|
inherit (cfg.search) command args;
|
|
|
|
pattern = helpers.ifNonNull' cfg.search.pattern (
|
|
|
|
if isList cfg.search.pattern then
|
2023-05-22 15:45:47 +05:30
|
|
|
(map helpers.mkRaw cfg.search.pattern)
|
2023-03-12 17:55:09 +01:00
|
|
|
else
|
|
|
|
helpers.mkRaw "[[${cfg.search.pattern}]]"
|
|
|
|
);
|
|
|
|
};
|
2023-03-09 22:00:04 -05:00
|
|
|
} // cfg.extraOptions;
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
2024-04-23 16:41:27 +02:00
|
|
|
extraPackages = [ cfg.ripgrepPackage ];
|
2023-03-09 22:00:04 -05:00
|
|
|
extraConfigLua = ''
|
|
|
|
require("todo-comments").setup${helpers.toLuaObject setupOptions}
|
|
|
|
'';
|
2023-03-12 11:49:41 +01:00
|
|
|
|
2023-09-15 14:35:13 +02:00
|
|
|
keymaps = flatten (
|
2023-03-12 11:49:41 +01:00
|
|
|
mapAttrsToList (
|
|
|
|
optionName: funcName:
|
|
|
|
let
|
2023-09-15 14:35:13 +02:00
|
|
|
keymap = cfg.keymaps.${optionName};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-05-22 15:45:47 +05:30
|
|
|
cwd = optionalString (keymap.cwd != null) " cwd=${keymap.cwd}";
|
|
|
|
keywords = optionalString (keymap.keywords != null) " keywords=${keymap.keywords}";
|
|
|
|
in
|
2023-09-15 14:35:13 +02:00
|
|
|
optional (keymap != null) {
|
|
|
|
mode = "n";
|
2023-11-06 15:53:26 +01:00
|
|
|
inherit (keymap) key options;
|
2023-09-15 14:35:13 +02:00
|
|
|
action = ":${funcName}${cwd}${keywords}<CR>";
|
2023-05-22 15:45:47 +05:30
|
|
|
}
|
2023-03-12 11:49:41 +01:00
|
|
|
) commands
|
|
|
|
);
|
|
|
|
|
|
|
|
# Automatically enable plugins if keymaps have been set
|
|
|
|
plugins = mkMerge [
|
2023-05-22 15:45:47 +05:30
|
|
|
(mkIf (cfg.keymaps.todoTrouble != null) { trouble.enable = true; })
|
|
|
|
(mkIf (cfg.keymaps.todoTelescope != null) { telescope.enable = true; })
|
2023-03-12 11:49:41 +01:00
|
|
|
];
|
2023-03-09 22:00:04 -05:00
|
|
|
};
|
|
|
|
}
|