plugins/obsidian: remove with lib and helpers

This commit is contained in:
Austin Horstman 2025-02-01 19:52:14 -06:00
parent 2b03933101
commit e68b8e9c91
No known key found for this signature in database
2 changed files with 67 additions and 65 deletions

View file

@ -183,7 +183,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
settingsOptions = settingsOptions =
let let
opts = import ./options.nix { inherit lib helpers; }; opts = import ./options.nix { inherit lib; };
in in
{ {
dir = helpers.mkNullOrOption types.str '' dir = helpers.mkNullOrOption types.str ''

View file

@ -1,42 +1,45 @@
{ lib, helpers }: { lib }:
with lib; let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
in
{ {
# https://github.com/epwalsh/obsidian.nvim/blob/main/lua/obsidian/config.lua # https://github.com/epwalsh/obsidian.nvim/blob/main/lua/obsidian/config.lua
log_level = helpers.defaultNullOpts.mkLogLevel "info" '' log_level = defaultNullOpts.mkLogLevel "info" ''
Set the log level for obsidian.nvim. Set the log level for obsidian.nvim.
''; '';
notes_subdir = helpers.mkNullOrStr '' notes_subdir = lib.nixvim.mkNullOrStr ''
If you keep notes in a specific subdirectory of your vault. If you keep notes in a specific subdirectory of your vault.
''; '';
templates = { templates = {
subdir = helpers.mkNullOrStr '' subdir = lib.nixvim.mkNullOrStr ''
The name of the directory where templates are stored. The name of the directory where templates are stored.
Example: "templates" Example: "templates"
''; '';
date_format = helpers.mkNullOrStr '' date_format = lib.nixvim.mkNullOrStr ''
Which date format to use. Which date format to use.
Example: "%Y-%m-%d" Example: "%Y-%m-%d"
''; '';
time_format = helpers.mkNullOrStr '' time_format = lib.nixvim.mkNullOrStr ''
Which time format to use. Which time format to use.
Example: "%H:%M" Example: "%H:%M"
''; '';
substitutions = helpers.defaultNullOpts.mkAttrsOf ( substitutions = defaultNullOpts.mkAttrsOf (
with lib.types; either str rawLua with lib.types; either str rawLua
) { } "A map for custom variables, the key should be the variable and the value a function."; ) { } "A map for custom variables, the key should be the variable and the value a function.";
}; };
new_notes_location = new_notes_location =
helpers.defaultNullOpts.mkEnumFirstDefault defaultNullOpts.mkEnumFirstDefault
[ [
"current_dir" "current_dir"
"notes_subdir" "notes_subdir"
@ -49,7 +52,7 @@ with lib;
- "notes_subdir" - put new notes in the default notes subdirectory. - "notes_subdir" - put new notes in the default notes subdirectory.
''; '';
note_id_func = helpers.mkNullOrLuaFn '' note_id_func = lib.nixvim.mkNullOrLuaFn ''
Customize how names/IDs for new notes are created. Customize how names/IDs for new notes are created.
Example: Example:
@ -73,7 +76,7 @@ with lib;
``` ```
''; '';
note_path_func = helpers.mkNullOrLuaFn '' note_path_func = lib.nixvim.mkNullOrLuaFn ''
Customize how note file names are generated given the ID, target directory, and title. Customize how note file names are generated given the ID, target directory, and title.
```lua ```lua
@ -91,7 +94,7 @@ with lib;
``` ```
''; '';
wiki_link_func = helpers.mkNullOrLuaFn '' wiki_link_func = lib.nixvim.mkNullOrLuaFn ''
Customize how wiki links are formatted. Customize how wiki links are formatted.
```lua ```lua
@ -115,7 +118,7 @@ with lib;
Default: See source Default: See source
''; '';
markdown_link_func = helpers.mkNullOrLuaFn '' markdown_link_func = lib.nixvim.mkNullOrLuaFn ''
Customize how markdown links are formatted. Customize how markdown links are formatted.
```lua ```lua
@ -134,7 +137,7 @@ with lib;
''; '';
preferred_link_style = preferred_link_style =
helpers.defaultNullOpts.mkEnumFirstDefault defaultNullOpts.mkEnumFirstDefault
[ [
"wiki" "wiki"
"markdown" "markdown"
@ -143,7 +146,7 @@ with lib;
Either 'wiki' or 'markdown'. Either 'wiki' or 'markdown'.
''; '';
follow_url_func = helpers.mkNullOrLuaFn '' follow_url_func = lib.nixvim.mkNullOrLuaFn ''
By default when you use `:ObsidianFollowLink` on a link to an external URL it will be By default when you use `:ObsidianFollowLink` on a link to an external URL it will be
ignored but you can customize this behavior here. ignored but you can customize this behavior here.
@ -157,7 +160,7 @@ with lib;
``` ```
''; '';
image_name_func = helpers.mkNullOrLuaFn '' image_name_func = lib.nixvim.mkNullOrLuaFn ''
Customize the default name or prefix when pasting images via `:ObsidianPasteImg`. Customize the default name or prefix when pasting images via `:ObsidianPasteImg`.
Example: Example:
@ -169,7 +172,7 @@ with lib;
``` ```
''; '';
note_frontmatter_func = helpers.mkNullOrLuaFn '' note_frontmatter_func = lib.nixvim.mkNullOrLuaFn ''
You can customize the frontmatter data. You can customize the frontmatter data.
Example: Example:
@ -195,7 +198,7 @@ with lib;
``` ```
''; '';
disable_frontmatter = helpers.mkNullOrStrLuaFnOr types.bool '' disable_frontmatter = lib.nixvim.mkNullOrStrLuaFnOr types.bool ''
Boolean or a function that takes a filename and returns a boolean. Boolean or a function that takes a filename and returns a boolean.
`true` indicates that you don't want obsidian.nvim to manage frontmatter. `true` indicates that you don't want obsidian.nvim to manage frontmatter.
@ -204,37 +207,36 @@ with lib;
completion = { completion = {
# FIXME should this accept raw types? # FIXME should this accept raw types?
nvim_cmp = helpers.mkNullOrOption' { nvim_cmp = lib.nixvim.mkNullOrOption' {
type = types.bool; type = types.bool;
description = '' description = ''
Set to false to disable completion. Set to false to disable completion.
''; '';
defaultText = literalMD "`true` if `plugins.cmp.enable` is enabled (otherwise `null`)."; defaultText = lib.literalMD "`true` if `plugins.cmp.enable` is enabled (otherwise `null`).";
}; };
min_chars = helpers.defaultNullOpts.mkUnsignedInt 2 '' min_chars = defaultNullOpts.mkUnsignedInt 2 ''
Trigger completion at this many chars. Trigger completion at this many chars.
''; '';
}; };
mappings = mappings =
helpers.defaultNullOpts.mkNullable defaultNullOpts.mkNullable
( (types.attrsOf (
with types; types.submodule {
attrsOf (submodule {
options = { options = {
action = mkOption { action = lib.mkOption {
type = lib.types.strLua; type = lib.types.strLua;
description = "The lua code for this keymap action."; description = "The lua code for this keymap action.";
}; };
opts = helpers.keymaps.mapConfigOptions // { opts = lib.nixvim.keymaps.mapConfigOptions // {
buffer = helpers.defaultNullOpts.mkBool false '' buffer = defaultNullOpts.mkBool false ''
If true, the mapping will be effective in the current buffer only. If true, the mapping will be effective in the current buffer only.
''; '';
}; };
}; };
}) }
) ))
{ {
gf = { gf = {
action = "require('obsidian').util.gf_passthrough"; action = "require('obsidian').util.gf_passthrough";
@ -256,7 +258,7 @@ with lib;
picker = { picker = {
name = name =
helpers.mkNullOrOption lib.nixvim.mkNullOrOption
(types.enum [ (types.enum [
"telescope.nvim" "telescope.nvim"
"fzf-lua" "fzf-lua"
@ -267,7 +269,7 @@ with lib;
''; '';
note_mappings = note_mappings =
helpers.defaultNullOpts.mkAttrsOf types.str defaultNullOpts.mkAttrsOf types.str
{ {
new = "<C-x>"; new = "<C-x>";
insert_link = "<C-l>"; insert_link = "<C-l>";
@ -278,7 +280,7 @@ with lib;
''; '';
tag_mappings = tag_mappings =
helpers.defaultNullOpts.mkAttrsOf types.str defaultNullOpts.mkAttrsOf types.str
{ {
tag_note = "<C-x>"; tag_note = "<C-x>";
insert_tag = "<C-l>"; insert_tag = "<C-l>";
@ -290,38 +292,38 @@ with lib;
}; };
daily_notes = { daily_notes = {
folder = helpers.mkNullOrStr '' folder = lib.nixvim.mkNullOrStr ''
Optional, if you keep daily notes in a separate directory. Optional, if you keep daily notes in a separate directory.
''; '';
date_format = helpers.mkNullOrStr '' date_format = lib.nixvim.mkNullOrStr ''
Optional, if you want to change the date format for the ID of daily notes. Optional, if you want to change the date format for the ID of daily notes.
Example: "%Y-%m-%d" Example: "%Y-%m-%d"
''; '';
alias_format = helpers.mkNullOrStr '' alias_format = lib.nixvim.mkNullOrStr ''
Optional, if you want to change the date format of the default alias of daily notes. Optional, if you want to change the date format of the default alias of daily notes.
Example: "%B %-d, %Y" Example: "%B %-d, %Y"
''; '';
template = helpers.mkNullOrStr '' template = lib.nixvim.mkNullOrStr ''
Optional, if you want to automatically insert a template from your template directory like Optional, if you want to automatically insert a template from your template directory like
'daily.md'. 'daily.md'.
''; '';
}; };
use_advanced_uri = helpers.defaultNullOpts.mkBool false '' use_advanced_uri = defaultNullOpts.mkBool false ''
Set to true to force ':ObsidianOpen' to bring the app to the foreground. Set to true to force ':ObsidianOpen' to bring the app to the foreground.
''; '';
open_app_foreground = helpers.defaultNullOpts.mkBool false '' open_app_foreground = defaultNullOpts.mkBool false ''
Set to true to force `:ObsidianOpen` to bring the app to the foreground. Set to true to force `:ObsidianOpen` to bring the app to the foreground.
''; '';
sort_by = sort_by =
helpers.defaultNullOpts.mkEnum defaultNullOpts.mkEnum
[ [
"path" "path"
"modified" "modified"
@ -335,12 +337,12 @@ with lib;
that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time. that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time.
''; '';
sort_reversed = helpers.defaultNullOpts.mkBool true '' sort_reversed = defaultNullOpts.mkBool true ''
Whether search results should be reversed. Whether search results should be reversed.
''; '';
open_notes_in = open_notes_in =
helpers.defaultNullOpts.mkEnumFirstDefault defaultNullOpts.mkEnumFirstDefault
[ [
"current" "current"
"vsplit" "vsplit"
@ -356,26 +358,26 @@ with lib;
''; '';
ui = { ui = {
enable = helpers.defaultNullOpts.mkBool true '' enable = defaultNullOpts.mkBool true ''
Set to false to disable all additional syntax features. Set to false to disable all additional syntax features.
''; '';
update_debounce = helpers.defaultNullOpts.mkUnsignedInt 200 '' update_debounce = defaultNullOpts.mkUnsignedInt 200 ''
Update delay after a text change (in milliseconds). Update delay after a text change (in milliseconds).
''; '';
checkboxes = checkboxes =
helpers.defaultNullOpts.mkAttrsOf defaultNullOpts.mkAttrsOf
( (
with types; with types;
submodule { submodule {
options = { options = {
char = mkOption { char = lib.mkOption {
type = with lib.types; maybeRaw str; type = with lib.types; maybeRaw str;
description = "The character to use for this checkbox."; description = "The character to use for this checkbox.";
}; };
hl_group = mkOption { hl_group = lib.mkOption {
type = with lib.types; maybeRaw str; type = with lib.types; maybeRaw str;
description = "The name of the highlight group to use for this checkbox."; description = "The name of the highlight group to use for this checkbox.";
}; };
@ -409,44 +411,44 @@ with lib;
''; '';
bullets = { bullets = {
char = helpers.defaultNullOpts.mkStr "" '' char = defaultNullOpts.mkStr "" ''
Which character to use for the bullets. Which character to use for the bullets.
''; '';
hl_group = helpers.defaultNullOpts.mkStr "ObsidianBullet" '' hl_group = defaultNullOpts.mkStr "ObsidianBullet" ''
The name of the highlight group to use for the bullets. The name of the highlight group to use for the bullets.
''; '';
}; };
external_link_icon = { external_link_icon = {
char = helpers.defaultNullOpts.mkStr "" '' char = defaultNullOpts.mkStr "" ''
Which character to use for the external link icon. Which character to use for the external link icon.
''; '';
hl_group = helpers.defaultNullOpts.mkStr "ObsidianExtLinkIcon" '' hl_group = defaultNullOpts.mkStr "ObsidianExtLinkIcon" ''
The name of the highlight group to use for the external link icon. The name of the highlight group to use for the external link icon.
''; '';
}; };
reference_text = { reference_text = {
hl_group = helpers.defaultNullOpts.mkStr "ObsidianRefText" '' hl_group = defaultNullOpts.mkStr "ObsidianRefText" ''
The name of the highlight group to use for reference text. The name of the highlight group to use for reference text.
''; '';
}; };
highlight_text = { highlight_text = {
hl_group = helpers.defaultNullOpts.mkStr "ObsidianHighlightText" '' hl_group = defaultNullOpts.mkStr "ObsidianHighlightText" ''
The name of the highlight group to use for highlight text. The name of the highlight group to use for highlight text.
''; '';
}; };
tags = { tags = {
hl_group = helpers.defaultNullOpts.mkStr "ObsidianTag" '' hl_group = defaultNullOpts.mkStr "ObsidianTag" ''
The name of the highlight group to use for tags. The name of the highlight group to use for tags.
''; '';
}; };
hl_groups = helpers.defaultNullOpts.mkAttrsOf lib.types.highlight { hl_groups = defaultNullOpts.mkAttrsOf lib.types.highlight {
ObsidianTodo = { ObsidianTodo = {
bold = true; bold = true;
fg = "#f78c6c"; fg = "#f78c6c";
@ -481,7 +483,7 @@ with lib;
}; };
attachments = { attachments = {
img_folder = helpers.defaultNullOpts.mkStr "assets/imgs" '' img_folder = defaultNullOpts.mkStr "assets/imgs" ''
The default folder to place images in via `:ObsidianPasteImg`. The default folder to place images in via `:ObsidianPasteImg`.
If this is a relative path it will be interpreted as relative to the vault root. If this is a relative path it will be interpreted as relative to the vault root.
@ -490,7 +492,7 @@ with lib;
''; '';
img_text_func = img_text_func =
helpers.defaultNullOpts.mkLuaFn defaultNullOpts.mkLuaFn
'' ''
function(client, path) function(client, path)
---@type string ---@type string
@ -518,37 +520,37 @@ with lib;
``` ```
''; '';
confirm_img_paste = helpers.defaultNullOpts.mkBool true '' confirm_img_paste = defaultNullOpts.mkBool true ''
Whether to prompt for confirmation when pasting an image. Whether to prompt for confirmation when pasting an image.
''; '';
}; };
callbacks = { callbacks = {
post_setup = helpers.mkNullOrLuaFn '' post_setup = lib.nixvim.mkNullOrLuaFn ''
`fun(client: obsidian.Client)` `fun(client: obsidian.Client)`
Runs right after the `obsidian.Client` is initialized. Runs right after the `obsidian.Client` is initialized.
''; '';
enter_note = helpers.mkNullOrLuaFn '' enter_note = lib.nixvim.mkNullOrLuaFn ''
`fun(client: obsidian.Client, note: obsidian.Note)` `fun(client: obsidian.Client, note: obsidian.Note)`
Runs when entering a note buffer. Runs when entering a note buffer.
''; '';
leave_note = helpers.mkNullOrLuaFn '' leave_note = lib.nixvim.mkNullOrLuaFn ''
`fun(client: obsidian.Client, note: obsidian.Note)` `fun(client: obsidian.Client, note: obsidian.Note)`
Runs when leaving a note buffer. Runs when leaving a note buffer.
''; '';
pre_write_note = helpers.mkNullOrLuaFn '' pre_write_note = lib.nixvim.mkNullOrLuaFn ''
`fun(client: obsidian.Client, note: obsidian.Note)` `fun(client: obsidian.Client, note: obsidian.Note)`
Runs right before writing a note buffer. Runs right before writing a note buffer.
''; '';
post_set_workspace = helpers.mkNullOrLuaFn '' post_set_workspace = lib.nixvim.mkNullOrLuaFn ''
`fun(client: obsidian.Client, workspace: obsidian.Workspace)` `fun(client: obsidian.Client, workspace: obsidian.Workspace)`
Runs anytime the workspace is set/changed. Runs anytime the workspace is set/changed.
@ -556,7 +558,7 @@ with lib;
}; };
yaml_parser = yaml_parser =
helpers.defaultNullOpts.mkEnumFirstDefault defaultNullOpts.mkEnumFirstDefault
[ [
"native" "native"
"yq" "yq"