From 2feaadc26664ee4e7f10b81a7ad71f0261de8534 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:46:16 +0100 Subject: [PATCH] feat(orgmode): custom setup --- modules/notes/orgmode/config.nix | 6 ++---- modules/notes/orgmode/orgmode.nix | 32 +++++++++++++++++++------------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 635f0f1..19be11d 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -6,6 +6,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.binds) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.notes.orgmode; in { @@ -37,10 +38,7 @@ in { }, } - require('orgmode').setup({ - org_agenda_files = ${cfg.orgAgendaFiles}, - org_default_notes_file = '${cfg.orgDefaultNotesFile}', - }) + require('orgmode').setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/notes/orgmode/orgmode.nix b/modules/notes/orgmode/orgmode.nix index 2a06605..1dad458 100644 --- a/modules/notes/orgmode/orgmode.nix +++ b/modules/notes/orgmode/orgmode.nix @@ -4,23 +4,31 @@ pkgs, ... }: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) str; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) str listOf; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; in { + imports = [ + (mkRenamedOptionModule ["vim" "notes" "orgmode" "orgAgendaFiles"] ["vim" "notes" "orgmode" "setupOpts" "org_agenda_files"]) + (mkRenamedOptionModule ["vim" "notes" "orgmode" "orgDefaultNotesFile"] ["vim" "notes" "orgmode" "setupOpts" "org_default_notes_file"]) + ]; + options.vim.notes.orgmode = { enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; - orgAgendaFiles = mkOption { - type = str; - default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; - description = "List of org files to be used as agenda files."; - }; + setupOpts = mkPluginSetupOption "Orgmode" { + org_agenda_files = mkOption { + type = listOf str; + default = ["~/Documents/org/*" "~/my-orgs/**/*"]; + description = "List of org files to be used as agenda files."; + }; - orgDefaultNotesFile = mkOption { - type = str; - default = "~/Documents/org/refile.org"; - description = "Default org file to be used for notes."; + org_default_notes_file = mkOption { + type = str; + default = "~/Documents/org/refile.org"; + description = "Default org file to be used for notes."; + }; }; treesitter = {