nix-community.nixvim/plugins/utils/obsidian/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

273 lines
5.5 KiB
Nix
Raw Normal View History

{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "obsidian";
originalName = "obsidian.nvim";
defaultPackage = pkgs.vimPlugins.obsidian-nvim;
maintainers = [ maintainers.GaetanLepage ];
## DEPRECATIONS
# Introduced 2024-03-12
# TODO: remove 2024-05-12
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"dir"
"logLevel"
"notesSubdir"
[
"templates"
"subdir"
]
[
"templates"
"dateFormat"
]
[
"templates"
"timeFormat"
]
[
"templates"
"substitutions"
]
"noteIdFunc"
"followUrlFunc"
"noteFrontmatterFunc"
"disableFrontmatter"
[
"completion"
"nvimCmp"
]
[
"completion"
"minChars"
]
"mappings"
[
"dailyNotes"
"folder"
]
[
"dailyNotes"
"dateFormat"
]
[
"dailyNotes"
"aliasFormat"
]
[
"dailyNotes"
"template"
]
"useAdvancedUri"
"openAppForeground"
"sortBy"
"sortReversed"
"openNotesIn"
[
"ui"
"enable"
]
[
"ui"
"updateDebounce"
]
[
"ui"
"externalLinkIcon"
"char"
]
2024-05-05 19:39:35 +02:00
[
"ui"
"externalLinkIcon"
"hlGroup"
]
[
"ui"
"referenceText"
"hlGroup"
]
[
"ui"
"highlightText"
"hlGroup"
]
[
"ui"
"tags"
2024-05-05 19:39:35 +02:00
"hlGroup"
]
[
"ui"
"hlGroups"
]
[
"attachments"
"imgFolder"
]
[
"attachments"
"imgTextFunc"
2024-05-05 19:39:35 +02:00
]
"yamlParser"
];
imports =
let
basePluginPath = [
"plugins"
"obsidian"
];
in
2024-05-05 19:39:35 +02:00
[
(
# We have to remove the option here because the user could set old-style camelCase options in each workspaces element.
mkRemovedOptionModule (
basePluginPath ++ [ "workspaces" ]
) "Please use `plugins.obsidian.settings.workspaces` instead."
2024-05-05 19:39:35 +02:00
)
(mkRenamedOptionModule (basePluginPath ++ [ "finder" ]) (
basePluginPath
2024-05-05 19:39:35 +02:00
++ [
"settings"
2024-05-05 19:39:35 +02:00
"picker"
"name"
]
))
(
# https://github.com/epwalsh/obsidian.nvim/blob/656d9c2c64528839db8b2d9a091843b3c90155a2/CHANGELOG.md?plain=1#L184
mkRenamedOptionModule
2024-05-05 19:39:35 +02:00
(
basePluginPath
2024-05-05 19:39:35 +02:00
++ [
"completion"
"newNotesLocation"
2024-05-05 19:39:35 +02:00
]
)
(
basePluginPath
2024-05-05 19:39:35 +02:00
++ [
"settings"
"new_notes_location"
2024-05-05 19:39:35 +02:00
]
)
)
(
# We have to remove the option here because the user could set old-style camelCase options in each checkbox element.
mkRemovedOptionModule (
basePluginPath
2024-05-05 19:39:35 +02:00
++ [
"ui"
"checkboxes"
2024-05-05 19:39:35 +02:00
]
) "Please use `plugins.obsidian.settings.ui.checkboxes` instead."
2024-05-05 19:39:35 +02:00
)
]
++ (map
(
optionPath:
mkRemovedOptionModule (basePluginPath ++ optionPath) "This option was deprecated by upstream."
2024-05-05 19:39:35 +02:00
)
[
[ "detectCwd" ]
[ "backlinks" ]
[
"completion"
"prependNoteId"
2024-05-05 19:39:35 +02:00
]
[
"completion"
"prependNotePath"
]
[
"completion"
"usePathOnly"
]
]
);
settingsOptions =
let
opts = import ./options.nix { inherit lib helpers; };
in
{
dir = helpers.mkNullOrOption types.str ''
Alternatively to `workspaces` - and for backwards compatibility - you can set `dir` to a
single path instead of `workspaces`.
For example:
```nix
dir = "~/vaults/work";
```
'';
workspaces =
helpers.defaultNullOpts.mkNullable
(
with types;
listOf (
types.submodule {
options = {
name = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The name for this workspace";
};
path = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The of the workspace.";
};
overrides = opts;
};
}
)
)
"[]"
''
A list of vault names and paths.
Each path should be the path to the vault root.
If you use the Obsidian app, the vault root is the parent directory of the `.obsidian`
folder.
You can also provide configuration overrides for each workspace through the `overrides`
field.
'';
}
// opts;
settingsExample = {
workspaces = [
{
name = "work";
path = "~/obsidian/work";
}
{
name = "startup";
path = "~/obsidian/startup";
}
];
new_notes_location = "current_dir";
completion = {
nvim_cmp = true;
min_chars = 2;
};
2024-05-05 19:39:35 +02:00
};
extraConfig = cfg: {
warnings =
let
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
in
optional (nvimCmpEnabled && !config.plugins.cmp.enable) ''
Nixvim (plugins.obsidian): You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
You should probably enable `nvim-cmp`.
'';
};
}