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

@ -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 {
"<leader>o" = "+Notes";
};
binds.whichKey.register = pushDownDefault {
"<leader>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}',"
}
}
})
'';
};
};
}

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