mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-09 06:55:30 +00:00
notes/obsidian-nvim: remove unnecessary options and add integrations/compat
This commit is contained in:
parent
f0c3b67d7c
commit
b9f641f34c
3 changed files with 120 additions and 36 deletions
|
|
@ -3,7 +3,8 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
|
@ -25,6 +26,48 @@ in {
|
|||
pluginRC.obsidian = entryAnywhere ''
|
||||
require("obsidian").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
|
||||
# Don't set option unless we have a useful setting for it.
|
||||
notes.obsidian.setupOpts = let
|
||||
snacks = config.vim.utility.snacks-nvim.setupOpts.picker.enabled or false;
|
||||
mini = config.vim.mini.pick.enable;
|
||||
telescope = config.vim.telescope.enable;
|
||||
fzf-lua = config.vim.fzf-lua.enable;
|
||||
|
||||
markdownExtensions = config.vim.languages.markdown.extensions;
|
||||
render-markdown = markdownExtensions.render-markdown-nvim.enable;
|
||||
markview = markdownExtensions.markview-nvim.enable;
|
||||
in
|
||||
mkMerge [
|
||||
(mkIf (snacks || mini || telescope || fzf-lua) {
|
||||
# plugin doesn't detect/choose this
|
||||
picker.name =
|
||||
if snacks
|
||||
then "snacks.pick"
|
||||
else if mini
|
||||
then "mini.pick"
|
||||
else if telescope
|
||||
then "telescope.nvim"
|
||||
else if fzf-lua
|
||||
then "fzf-lua"
|
||||
# NOTE: Shouldn't happen
|
||||
else null;
|
||||
})
|
||||
# Should be disabled automatically, but still causes issues in checkhealth.
|
||||
(mkIf (render-markdown || markview) {ui.enable = false;})
|
||||
];
|
||||
|
||||
# Resolve markdown image paths in the vault.
|
||||
# Only actually used by snacks if image.enabled is set to true
|
||||
utility.snacks-nvim.setupOpts = mkIf config.vim.utility.snacks-nvim.enable {
|
||||
image.resolve = mkLuaInline ''
|
||||
function(path, src)
|
||||
if require("obsidian.api").path_is_note(path) then
|
||||
return require("obsidian.api").resolve_image_path(src)
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool str nullOr;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.modules) mkRenamedOptionModule mkRemovedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
autocompleteCfg = config.vim.autocomplete;
|
||||
in {
|
||||
imports = let
|
||||
renamedSetupOption = oldPath: newPath:
|
||||
|
|
@ -16,38 +9,48 @@ in {
|
|||
(["vim" "notes" "obsidian"] ++ oldPath)
|
||||
(["vim" "notes" "obsidian" "setupOpts"] ++ newPath);
|
||||
in [
|
||||
(renamedSetupOption ["dir"] ["dir"])
|
||||
(
|
||||
mkRemovedOptionModule ["vim" "notes" "obsidian" "dir"]
|
||||
''
|
||||
`obsidian.nvim` has migrated to the `setupOpts.workspaces` option to support multiple vaults with a single interface.
|
||||
|
||||
To continue using a single vault, set:
|
||||
|
||||
```nix
|
||||
{
|
||||
notes.obsidian.setupOpts.workspaces = [
|
||||
{
|
||||
name = "any-string";
|
||||
path = "~/old/dir/path/value";
|
||||
}
|
||||
];
|
||||
}
|
||||
```
|
||||
''
|
||||
)
|
||||
(renamedSetupOption ["daily-notes" "folder"] ["daily_notes" "folder"])
|
||||
(renamedSetupOption ["daily-notes" "date-format"] ["daily_notes" "date_format"])
|
||||
(renamedSetupOption ["completion"] ["completion"])
|
||||
];
|
||||
options.vim.notes = {
|
||||
obsidian = {
|
||||
enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
|
||||
enable =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
description = ''
|
||||
Whether to enable plugins to compliment the Obsidian markdown editor [obsidian.nvim].
|
||||
|
||||
setupOpts = mkPluginSetupOption "Obsidian.nvim" {
|
||||
daily_notes = {
|
||||
folder = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Directory in which daily notes should be created";
|
||||
};
|
||||
date_format = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Date format used for creating daily notes";
|
||||
};
|
||||
This plugin depends on [vim-markdown] which by default folds headings, including outside of workspaces/vaults.
|
||||
Set `vim.g['vim_markdown_folding_disable'] = 1` to disable automatic folding,
|
||||
or `vim.g['vim_markdown_folding_level'] = <number>` to set the default folding level.
|
||||
|
||||
nvf will choose snacks.picker, mini.pick, telescope, or fzf-lua as the picker if they are enabled, in that order.
|
||||
|
||||
The `ui` config module is automatically disabled if `render-markdown-nvim` or `markview-nvim` are enabled.
|
||||
'';
|
||||
};
|
||||
|
||||
completion = {
|
||||
nvim_cmp = mkOption {
|
||||
# If using nvim-cmp, otherwise set to false
|
||||
type = bool;
|
||||
description = "If using nvim-cmp, otherwise set to false";
|
||||
default = autocompleteCfg.nvim-cmp.enable || autocompleteCfg.blink-cmp.enable;
|
||||
};
|
||||
};
|
||||
};
|
||||
setupOpts = mkPluginSetupOption "obsidian.nvim" {};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue