modules/notes: switch to explicit lib calls

This commit is contained in:
raf 2024-03-12 03:47:01 +03:00
commit 2101ac9061
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
13 changed files with 154 additions and 144 deletions

View file

@ -4,46 +4,49 @@
lib,
...
}: let
inherit (lib) mkMerge mkBinding mkIf;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
cfg = config.vim.notes.todo-comments;
self = import ./todo-comments.nix {inherit lib;};
mappings = self.options.vim.notes.todo-comments.mappings;
inherit (self.options.vim.notes.todo-comments) mappings;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"todo-comments"
];
config = mkIf cfg.enable {
vim = {
startPlugins = [
"todo-comments"
];
vim.maps.normal = mkMerge [
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
];
maps.normal = mkMerge [
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
];
vim.luaConfigRC.todo-comments = ''
require('todo-comments').setup {
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",
luaConfigRC.todo-comments = ''
require('todo-comments').setup {
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
},
pattern = ${cfg.patterns.search},
},
}
'';
search = {
command = "${pkgs.ripgrep}/bin/rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
pattern = ${cfg.patterns.search},
},
}
'';
};
};
}

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./todo-comments.nix
./config.nix

View file

@ -1,18 +1,20 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.notes.todo-comments = {
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
patterns = {
highlight = mkOption {
type = types.str;
type = str;
default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]'';
description = "vim regex pattern used for highlighting comments";
};
search = mkOption {
type = types.str;
type = str;
default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]'';
description = "ripgrep regex pattern used for searching comments";
};