From 1c66c6ff65f5f89946706b8539b69bf329862a7d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 Mar 2023 13:26:58 +0300 Subject: [PATCH] feat: add todo-comments options --- modules/notes/default.nix | 1 + modules/notes/todo-comments/config.nix | 47 +++++++++++++++++++ modules/notes/todo-comments/default.nix | 6 +++ modules/notes/todo-comments/todo-comments.nix | 28 +++++++++++ 4 files changed, 82 insertions(+) create mode 100644 modules/notes/todo-comments/config.nix create mode 100644 modules/notes/todo-comments/default.nix create mode 100644 modules/notes/todo-comments/todo-comments.nix diff --git a/modules/notes/default.nix b/modules/notes/default.nix index b8c2059..eaf247f 100644 --- a/modules/notes/default.nix +++ b/modules/notes/default.nix @@ -3,5 +3,6 @@ _: { ./obsidian ./orgmode ./mind-nvim + ./todo-comments ]; } diff --git a/modules/notes/todo-comments/config.nix b/modules/notes/todo-comments/config.nix new file mode 100644 index 0000000..c04aa8d --- /dev/null +++ b/modules/notes/todo-comments/config.nix @@ -0,0 +1,47 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.todo-comments; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "todo-comments" + ]; + + vim.nnoremap = { + "tdq" = ":TodoQuickFix"; + "tds" = ":TodoTelescope"; + "tdt" = ":TodoTrouble"; + }; + + 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", + }, + pattern = ${cfg.patterns.search}, + }, + } + ''; + }; +} diff --git a/modules/notes/todo-comments/default.nix b/modules/notes/todo-comments/default.nix new file mode 100644 index 0000000..ac730fe --- /dev/null +++ b/modules/notes/todo-comments/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./todo-comments.nix + ./config.nix + ]; +} diff --git a/modules/notes/todo-comments/todo-comments.nix b/modules/notes/todo-comments/todo-comments.nix new file mode 100644 index 0000000..ec445eb --- /dev/null +++ b/modules/notes/todo-comments/todo-comments.nix @@ -0,0 +1,28 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.todo-comments; +in { + options.vim.notes.todo-comments = { + enable = mkEnableOption "todo-comments"; + + patterns = { + highlight = mkOption { + type = types.str; + default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]''; + description = "vim regex pattern used for highlighting comments"; + }; + + search = mkOption { + type = types.str; + default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]''; + description = "ripgrep regex pattern used for searching comments"; + }; + }; + }; +}