diff --git a/modules/notes/default.nix b/modules/notes/default.nix index eaf247f..88a7092 100644 --- a/modules/notes/default.nix +++ b/modules/notes/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./obsidian ./orgmode diff --git a/modules/notes/mind-nvim/config.nix b/modules/notes/mind-nvim/config.nix index 8a609b0..7f7ea9d 100644 --- a/modules/notes/mind-nvim/config.nix +++ b/modules/notes/mind-nvim/config.nix @@ -3,27 +3,31 @@ lib, ... }: let - inherit (lib) mkIf nvim pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.mind-nvim; in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "mind-nvim" - ]; + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "mind-nvim" + ]; - vim.maps.normal = { - "om" = {action = ":MindOpenMain";}; - "op" = {action = ":MindOpenProject";}; - "oc" = {action = ":MindClose";}; + maps.normal = { + "om" = {action = ":MindOpenMain";}; + "op" = {action = ":MindOpenProject";}; + "oc" = {action = ":MindClose";}; + }; + + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + luaConfigRC.mind-nvim = entryAnywhere '' + require'mind'.setup() + ''; }; - - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; - }; - - vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere '' - require'mind'.setup() - ''; }; } diff --git a/modules/notes/mind-nvim/default.nix b/modules/notes/mind-nvim/default.nix index e136b9d..be25fff 100644 --- a/modules/notes/mind-nvim/default.nix +++ b/modules/notes/mind-nvim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./mind-nvim.nix ./config.nix diff --git a/modules/notes/mind-nvim/mind-nvim.nix b/modules/notes/mind-nvim/mind-nvim.nix index f0d43ea..ad1a395 100644 --- a/modules/notes/mind-nvim/mind-nvim.nix +++ b/modules/notes/mind-nvim/mind-nvim.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.notes.mind-nvim = { - enable = mkEnableOption "organizer tool for Neovim."; + enable = mkEnableOption "note organizer tool for Neovim [mind-nvim]"; }; } diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix index f521c62..818d447 100644 --- a/modules/notes/obsidian/config.nix +++ b/modules/notes/obsidian/config.nix @@ -3,45 +3,49 @@ lib, ... }: let - inherit (lib) mkIf nvim pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.obsidian; auto = config.vim.autocomplete; in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "obsidian-nvim" - "vim-markdown" - "tabular" - ]; + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "obsidian-nvim" + "vim-markdown" + "tabular" + ]; - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; - }; + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; - vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere '' - require("obsidian").setup({ - dir = "${cfg.dir}", - completion = { - nvim_cmp = ${ - if (auto.type == "nvim-cmp") - then "true" - else "false" - } - }, - daily_notes = { - folder = ${ - if (cfg.daily-notes.folder == "") - then "nil," - else "'${cfg.daily-notes.folder}'," - } - date_format = ${ - if (cfg.daily-notes.date-format == "") - then "nil," - else "'${cfg.daily-notes.date-format}'," - } + luaConfigRC.obsidian = entryAnywhere '' + require("obsidian").setup({ + dir = "${cfg.dir}", + completion = { + nvim_cmp = ${ + if (auto.type == "nvim-cmp") + then "true" + else "false" } - }) - ''; + }, + daily_notes = { + folder = ${ + if (cfg.daily-notes.folder == "") + then "nil," + else "'${cfg.daily-notes.folder}'," + } + date_format = ${ + if (cfg.daily-notes.date-format == "") + then "nil," + else "'${cfg.daily-notes.date-format}'," + } + } + }) + ''; + }; }; } diff --git a/modules/notes/obsidian/default.nix b/modules/notes/obsidian/default.nix index d73bfc2..db8c675 100644 --- a/modules/notes/obsidian/default.nix +++ b/modules/notes/obsidian/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./obsidian.nix ./config.nix diff --git a/modules/notes/obsidian/obsidian.nix b/modules/notes/obsidian/obsidian.nix index cfc0eda..1b7bae6 100644 --- a/modules/notes/obsidian/obsidian.nix +++ b/modules/notes/obsidian/obsidian.nix @@ -1,27 +1,24 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) str bool; in { options.vim.notes = { obsidian = { enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; dir = mkOption { - type = types.str; + type = str; default = "~/my-vault"; description = "Obsidian vault directory"; }; daily-notes = { folder = mkOption { - type = types.str; + type = str; default = ""; description = "Directory in which daily notes should be created"; }; date-format = mkOption { - type = types.str; + type = str; default = ""; description = "Date format used for creating daily notes"; }; @@ -29,8 +26,7 @@ in { completion = { nvim_cmp = mkOption { - # if using nvim-cmp, otherwise set to false - type = types.bool; + type = bool; description = "If using nvim-cmp, otherwise set to false"; }; }; diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 08df2de..635f0f1 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -3,42 +3,46 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.orgmode; in { config = mkIf cfg.enable (mkMerge [ { - vim.startPlugins = [ - "orgmode-nvim" - ]; + vim = { + startPlugins = [ + "orgmode-nvim" + ]; - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + luaConfigRC.orgmode = entryAnywhere '' + -- Load custom treesitter grammar for org filetype + require('orgmode').setup_ts_grammar() + + -- Treesitter configuration + require('nvim-treesitter.configs').setup { + + -- If TS highlights are not enabled at all, or disabled via `disable` prop, + -- highlighting will fallback to default Vim syntax highlighting + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = {'org'}, + }, + } + + require('orgmode').setup({ + org_agenda_files = ${cfg.orgAgendaFiles}, + org_default_notes_file = '${cfg.orgDefaultNotesFile}', + }) + ''; }; - - vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' - -- Load custom treesitter grammar for org filetype - require('orgmode').setup_ts_grammar() - - -- Treesitter configuration - require('nvim-treesitter.configs').setup { - - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = {'org'}, - }, - } - - require('orgmode').setup({ - org_agenda_files = ${cfg.orgAgendaFiles}, - org_default_notes_file = '${cfg.orgDefaultNotesFile}', - }) - ''; } (mkIf cfg.treesitter.enable { diff --git a/modules/notes/orgmode/default.nix b/modules/notes/orgmode/default.nix index 299c754..c4f5a1a 100644 --- a/modules/notes/orgmode/default.nix +++ b/modules/notes/orgmode/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./orgmode.nix ./config.nix diff --git a/modules/notes/orgmode/orgmode.nix b/modules/notes/orgmode/orgmode.nix index d7fce12..2a06605 100644 --- a/modules/notes/orgmode/orgmode.nix +++ b/modules/notes/orgmode/orgmode.nix @@ -4,27 +4,28 @@ pkgs, ... }: let - inherit (lib) mkEnableOption types mkOption nvim; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) str; + inherit (lib.nvim.types) mkGrammarOption; in { options.vim.notes.orgmode = { enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; orgAgendaFiles = mkOption { - type = types.str; + type = str; default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; description = "List of org files to be used as agenda files."; }; orgDefaultNotesFile = mkOption { - type = types.str; + type = str; default = "~/Documents/org/refile.org"; description = "Default org file to be used for notes."; }; treesitter = { enable = mkEnableOption "Orgmode treesitter" // {default = config.vim.languages.enableTreesitter;}; - - orgPackage = nvim.types.mkGrammarOption pkgs "org"; + orgPackage = mkGrammarOption pkgs "org"; }; }; } diff --git a/modules/notes/todo-comments/config.nix b/modules/notes/todo-comments/config.nix index f1ced60..8db653f 100644 --- a/modules/notes/todo-comments/config.nix +++ b/modules/notes/todo-comments/config.nix @@ -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" mappings.quickFix.description) - (mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope" mappings.telescope.description)) - (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" mappings.trouble.description)) - ]; + maps.normal = mkMerge [ + (mkBinding cfg.mappings.quickFix ":TodoQuickFix" mappings.quickFix.description) + (mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope" mappings.telescope.description)) + (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" 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}, + }, + } + ''; + }; }; } diff --git a/modules/notes/todo-comments/default.nix b/modules/notes/todo-comments/default.nix index ac730fe..6030067 100644 --- a/modules/notes/todo-comments/default.nix +++ b/modules/notes/todo-comments/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./todo-comments.nix ./config.nix diff --git a/modules/notes/todo-comments/todo-comments.nix b/modules/notes/todo-comments/todo-comments.nix index 6fbc71b..ca4e4be 100644 --- a/modules/notes/todo-comments/todo-comments.nix +++ b/modules/notes/todo-comments/todo-comments.nix @@ -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"; };