modules/notes: switch to explicit lib calls

This commit is contained in:
raf 2024-03-12 03:47:01 +03:00
parent f6db808bfc
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

@ -1,4 +1,4 @@
_: {
{
imports = [
./obsidian
./orgmode

View file

@ -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 = [
config = mkIf cfg.enable {
vim = {
startPlugins = [
"mind-nvim"
];
vim.maps.normal = {
maps.normal = {
"<leader>om" = {action = ":MindOpenMain<CR>";};
"<leader>op" = {action = ":MindOpenProject<CR>";};
"<leader>oc" = {action = ":MindClose<CR>";};
};
vim.binds.whichKey.register = pushDownDefault {
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
luaConfigRC.mind-nvim = entryAnywhere ''
require'mind'.setup()
'';
};
};
}

View file

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

View file

@ -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]";
};
}

View file

@ -3,23 +3,26 @@
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 = [
config = mkIf cfg.enable {
vim = {
startPlugins = [
"obsidian-nvim"
"vim-markdown"
"tabular"
];
vim.binds.whichKey.register = pushDownDefault {
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere ''
luaConfigRC.obsidian = entryAnywhere ''
require("obsidian").setup({
dir = "${cfg.dir}",
completion = {
@ -44,4 +47,5 @@ in {
})
'';
};
};
}

View file

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

View file

@ -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";
};
};

View file

@ -3,21 +3,24 @@
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 = [
vim = {
startPlugins = [
"orgmode-nvim"
];
vim.binds.whichKey.register = pushDownDefault {
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere ''
luaConfigRC.orgmode = entryAnywhere ''
-- Load custom treesitter grammar for org filetype
require('orgmode').setup_ts_grammar()
@ -39,6 +42,7 @@ in {
org_default_notes_file = '${cfg.orgDefaultNotesFile}',
})
'';
};
}
(mkIf cfg.treesitter.enable {

View file

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

View file

@ -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";
};
};
}

View file

@ -4,24 +4,26 @@
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 = [
config = mkIf cfg.enable {
vim = {
startPlugins = [
"todo-comments"
];
vim.maps.normal = mkMerge [
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 = ''
luaConfigRC.todo-comments = ''
require('todo-comments').setup {
highlight = {
before = "", -- "fg" or "bg" or empty
@ -46,4 +48,5 @@ in {
}
'';
};
};
}

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";
};