mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-02 09:05:55 +00:00
notes/obsidian-nvim: remove unnecessary options and add integrations/compat
This commit is contained in:
parent
f63a196ed7
commit
1eddd990fc
3 changed files with 174 additions and 39 deletions
|
|
@ -3,9 +3,9 @@
|
|||
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;
|
||||
|
||||
cfg = config.vim.notes.obsidian;
|
||||
|
|
@ -18,13 +18,58 @@ in {
|
|||
"tabular"
|
||||
];
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
};
|
||||
|
||||
pluginRC.obsidian = entryAnywhere ''
|
||||
require("obsidian").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
|
||||
notes.obsidian.setupOpts = let
|
||||
# may not be defined
|
||||
snacks-picker.enable = config.vim.utility.snacks-nvim.setupOpts.picker.enabled or false;
|
||||
mini-pick = config.vim.mini.pick;
|
||||
inherit (config.vim) telescope fzf-lua;
|
||||
|
||||
inherit (config.vim.languages.markdown.extensions) render-markdown-nvim markview-nvim;
|
||||
in
|
||||
mkMerge [
|
||||
# Don't set option unless we have a useful setting for it.
|
||||
(mkIf (snacks-picker.enable || mini-pick.enable || telescope.enable || fzf-lua.enable) {
|
||||
# It doesn't detect/choose this.
|
||||
# Some pickers and completion plugins don't get detected correctly by the checkhealth, but they all work.
|
||||
# Values taken from the [config's](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/lua/obsidian/config/init.lua) valid ones.
|
||||
picker.name =
|
||||
if snacks-picker.enable
|
||||
then "snacks.pick"
|
||||
else if mini-pick.enable
|
||||
then "mini.pick"
|
||||
else if telescope.enable
|
||||
then "telescope.nvim"
|
||||
else if fzf-lua.enable
|
||||
then "fzf-lua"
|
||||
# NOTE: Shouldn't happen with the if-guard.
|
||||
else null;
|
||||
})
|
||||
|
||||
# Should be disabled automatically, but still shows up in render-markdown's checkhealth.
|
||||
# This is also useful in that it will conflict with a user explicitly enabling it
|
||||
# without mkForce, which is probably a copy paste issue and a sign to look at
|
||||
# whether this option is useful.
|
||||
(mkIf (render-markdown-nvim.enable || markview-nvim.enable) {ui.enable = false;})
|
||||
];
|
||||
|
||||
# Resolve markdown image paths in the vault.
|
||||
# Only actually used by snacks if image.enabled is set to true and
|
||||
# required programs are supplied and `attachments.img_folder` is correct.
|
||||
# From https://github.com/obsidian-nvim/obsidian.nvim/wiki/Images,
|
||||
# which notes the API might change.
|
||||
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,60 @@ 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";
|
||||
}
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
See the [wiki](https://github.com/obsidian-nvim/obsidian.nvim/wiki/Workspace#vault-based-workspaces) for more information.
|
||||
''
|
||||
)
|
||||
(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 complement 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";
|
||||
};
|
||||
Enables [vim-markdown] which automatically folds markdown headings inside and outside of workspaces/vaults.
|
||||
Set {option}`vim.globals.vim_markdown_folding_disable = 1;` to disable automatic folding,
|
||||
or {option}`vim.globals.vim_markdown_folding_level = <heading-level-int>;` to set the default fold level for new buffers.
|
||||
|
||||
nvf will choose one of `snacks.picker`, `mini.pick`, `telescope`, or `fzf-lua` as the `obsidian.nvim` picker based on whether they are enabled, in that order.
|
||||
|
||||
You can enable one of them with one of the following:
|
||||
|
||||
- {option}`vim.utility.snacks-nvim.setupOpts.picker.enabled` and {option}`vim.utility.snacks-nvim.enable`
|
||||
- {option}`vim.mini.pick.enable`
|
||||
- {option}`vim.telescope.enable`
|
||||
- {option}`vim.fzf-lua.enable`
|
||||
|
||||
{option}`vim.notes.obsidian.setupOpts.ui.enable` is automatically disabled if `render-markdown.nvim` or `markview.nvim` are enabled.
|
||||
|
||||
[vim-markdown]: https://github.com/preservim/vim-markdown?tab=readme-ov-file#options
|
||||
'';
|
||||
};
|
||||
|
||||
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