mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-21 17:59:48 +01:00
feat(todo-comments): custom setup
This commit is contained in:
parent
2feaadc266
commit
3f4ef987dd
2 changed files with 45 additions and 38 deletions
|
@ -4,11 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib) mkMerge mkBinding mkIf;
|
||||||
inherit (lib.nvim.binds) mkBinding;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.notes.todo-comments;
|
cfg = config.vim.notes.todo-comments;
|
||||||
self = import ./todo-comments.nix {inherit lib;};
|
self = import ./todo-comments.nix {inherit pkgs lib;};
|
||||||
inherit (self.options.vim.notes.todo-comments) mappings;
|
inherit (self.options.vim.notes.todo-comments) mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -24,28 +24,7 @@ in {
|
||||||
];
|
];
|
||||||
|
|
||||||
luaConfigRC.todo-comments = ''
|
luaConfigRC.todo-comments = ''
|
||||||
require('todo-comments').setup {
|
require('todo-comments').setup(${toLuaObject cfg.setupOpts})
|
||||||
highlight = {
|
|
||||||
before = "", -- "fg" or "bg" or empty
|
|
||||||
keyword = "bg", -- "fg", "bg", "wide" or empty
|
|
||||||
after = "fg", -- "fg" or "bg" or empty
|
|
||||||
pattern = ${cfg.patterns.highlight},
|
|
||||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
|
||||||
max_line_len = 400, -- ignore lines longer than this
|
|
||||||
exclude = {}, -- list of file types to exclude highlighting
|
|
||||||
},
|
|
||||||
search = {
|
|
||||||
command = "${pkgs.ripgrep}/bin/rg",
|
|
||||||
args = {
|
|
||||||
"--color=never",
|
|
||||||
"--no-heading",
|
|
||||||
"--with-filename",
|
|
||||||
"--line-number",
|
|
||||||
"--column",
|
|
||||||
},
|
|
||||||
pattern = ${cfg.patterns.search},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,22 +1,50 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
pkgs,
|
||||||
inherit (lib.types) str;
|
lib,
|
||||||
inherit (lib.nvim.binds) mkMappingOption;
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption types mkMappingOption mkRenamedOptionModule;
|
||||||
in {
|
in {
|
||||||
|
imports = let
|
||||||
|
renamedSetupOption = oldPath: newPath:
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(["vim" "notes" "todo-comments"] ++ oldPath)
|
||||||
|
(["vim" "notes" "todo-comments" "setupOpts"] ++ newPath);
|
||||||
|
in [
|
||||||
|
(renamedSetupOption ["patterns" "highlight"] ["highlight" "pattern"])
|
||||||
|
(renamedSetupOption ["patterns" "search"] ["search" "pattern"])
|
||||||
|
];
|
||||||
|
|
||||||
options.vim.notes.todo-comments = {
|
options.vim.notes.todo-comments = {
|
||||||
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
|
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
|
||||||
|
|
||||||
patterns = {
|
setupOpts = lib.nvim.types.mkPluginSetupOption "todo-comments.nvim" {
|
||||||
highlight = mkOption {
|
highlight = {
|
||||||
type = str;
|
pattern = mkOption {
|
||||||
default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]'';
|
type = types.str;
|
||||||
description = "vim regex pattern used for highlighting comments";
|
default = ''.*<(KEYWORDS)(\([^\)]*\))?:'';
|
||||||
|
description = "vim regex pattern used for highlighting comments";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
search = mkOption {
|
search = {
|
||||||
type = str;
|
pattern = mkOption {
|
||||||
default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]'';
|
type = types.str;
|
||||||
description = "ripgrep regex pattern used for searching comments";
|
default = ''\b(KEYWORDS)(\([^\)]*\))?:'';
|
||||||
|
description = "ripgrep regex pattern used for searching comments";
|
||||||
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "${pkgs.ripgrep}/bin/rg";
|
||||||
|
description = "search command";
|
||||||
|
};
|
||||||
|
|
||||||
|
args = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = ["--color=never" "--no-heading" "--with-filename" "--line-number" "--column"];
|
||||||
|
description = "arguments to pass to the search command";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue