mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-02 21:34:33 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -1,8 +1,6 @@
|
|||
{ lib, helpers }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
helpers,
|
||||
}:
|
||||
with lib; {
|
||||
# https://github.com/epwalsh/obsidian.nvim/blob/main/lua/obsidian/config.lua
|
||||
|
||||
log_level = helpers.defaultNullOpts.mkLogLevel "info" ''
|
||||
|
@ -32,20 +30,24 @@ with lib; {
|
|||
Example: "%H:%M"
|
||||
'';
|
||||
|
||||
substitutions =
|
||||
helpers.defaultNullOpts.mkAttrsOf
|
||||
(with helpers.nixvimTypes; either str rawLua)
|
||||
"{}"
|
||||
"A map for custom variables, the key should be the variable and the value a function.";
|
||||
substitutions = helpers.defaultNullOpts.mkAttrsOf (
|
||||
with helpers.nixvimTypes; either str rawLua
|
||||
) "{}" "A map for custom variables, the key should be the variable and the value a function.";
|
||||
};
|
||||
|
||||
new_notes_location = helpers.defaultNullOpts.mkEnumFirstDefault ["current_dir" "notes_subdir"] ''
|
||||
Where to put new notes created from completion.
|
||||
new_notes_location =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"current_dir"
|
||||
"notes_subdir"
|
||||
]
|
||||
''
|
||||
Where to put new notes created from completion.
|
||||
|
||||
Valid options are
|
||||
- "current_dir" - put new notes in same directory as the current buffer.
|
||||
- "notes_subdir" - put new notes in the default notes subdirectory.
|
||||
'';
|
||||
Valid options are
|
||||
- "current_dir" - put new notes in same directory as the current buffer.
|
||||
- "notes_subdir" - put new notes in the default notes subdirectory.
|
||||
'';
|
||||
|
||||
note_id_func = helpers.mkNullOrLuaFn ''
|
||||
Customize how names/IDs for new notes are created.
|
||||
|
@ -89,31 +91,29 @@ with lib; {
|
|||
```
|
||||
'';
|
||||
|
||||
wiki_link_func =
|
||||
helpers.mkNullOrLuaFn
|
||||
''
|
||||
Customize how wiki links are formatted.
|
||||
wiki_link_func = helpers.mkNullOrLuaFn ''
|
||||
Customize how wiki links are formatted.
|
||||
|
||||
```lua
|
||||
---@param opts {path: string, label: string, id: string|?}
|
||||
---@return string
|
||||
```
|
||||
```lua
|
||||
---@param opts {path: string, label: string, id: string|?}
|
||||
---@return string
|
||||
```
|
||||
|
||||
Example:
|
||||
```lua
|
||||
function(opts)
|
||||
if opts.id == nil then
|
||||
return string.format("[[%s]]", opts.label)
|
||||
elseif opts.label ~= opts.id then
|
||||
return string.format("[[%s|%s]]", opts.id, opts.label)
|
||||
else
|
||||
return string.format("[[%s]]", opts.id)
|
||||
end
|
||||
Example:
|
||||
```lua
|
||||
function(opts)
|
||||
if opts.id == nil then
|
||||
return string.format("[[%s]]", opts.label)
|
||||
elseif opts.label ~= opts.id then
|
||||
return string.format("[[%s|%s]]", opts.id, opts.label)
|
||||
else
|
||||
return string.format("[[%s]]", opts.id)
|
||||
end
|
||||
```
|
||||
end
|
||||
```
|
||||
|
||||
Default: See source
|
||||
'';
|
||||
Default: See source
|
||||
'';
|
||||
|
||||
markdown_link_func = helpers.mkNullOrLuaFn ''
|
||||
Customize how markdown links are formatted.
|
||||
|
@ -133,9 +133,15 @@ with lib; {
|
|||
Default: See source
|
||||
'';
|
||||
|
||||
preferred_link_style = helpers.defaultNullOpts.mkEnumFirstDefault ["wiki" "markdown"] ''
|
||||
Either 'wiki' or 'markdown'.
|
||||
'';
|
||||
preferred_link_style =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"wiki"
|
||||
"markdown"
|
||||
]
|
||||
''
|
||||
Either 'wiki' or 'markdown'.
|
||||
'';
|
||||
|
||||
follow_url_func = helpers.mkNullOrLuaFn ''
|
||||
By default when you use `:ObsidianFollowLink` on a link to an external URL it will be
|
||||
|
@ -210,8 +216,8 @@ with lib; {
|
|||
|
||||
mappings =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
(
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
action = mkOption {
|
||||
|
@ -219,67 +225,72 @@ with lib; {
|
|||
description = "The lua code for this keymap action.";
|
||||
apply = helpers.mkRaw;
|
||||
};
|
||||
opts =
|
||||
helpers.keymaps.mapConfigOptions
|
||||
// {
|
||||
buffer = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, the mapping will be effective in the current buffer only.
|
||||
'';
|
||||
};
|
||||
opts = helpers.keymaps.mapConfigOptions // {
|
||||
buffer = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, the mapping will be effective in the current buffer only.
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
)
|
||||
''
|
||||
{
|
||||
gf = {
|
||||
action = "require('obsidian').util.gf_passthrough";
|
||||
opts = {
|
||||
noremap = false;
|
||||
expr = true;
|
||||
buffer = true;
|
||||
)
|
||||
''
|
||||
{
|
||||
gf = {
|
||||
action = "require('obsidian').util.gf_passthrough";
|
||||
opts = {
|
||||
noremap = false;
|
||||
expr = true;
|
||||
buffer = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
"<leader>ch" = {
|
||||
action = "require('obsidian').util.toggle_checkbox";
|
||||
opts.buffer = true;
|
||||
};
|
||||
}
|
||||
''
|
||||
''
|
||||
Configure key mappings.
|
||||
'';
|
||||
"<leader>ch" = {
|
||||
action = "require('obsidian').util.toggle_checkbox";
|
||||
opts.buffer = true;
|
||||
};
|
||||
}
|
||||
''
|
||||
''
|
||||
Configure key mappings.
|
||||
'';
|
||||
|
||||
picker = {
|
||||
name = helpers.mkNullOrOption (types.enum ["telescope.nvim" "fzf-lua" "mini.pick"]) ''
|
||||
Set your preferred picker.
|
||||
'';
|
||||
name =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"telescope.nvim"
|
||||
"fzf-lua"
|
||||
"mini.pick"
|
||||
])
|
||||
''
|
||||
Set your preferred picker.
|
||||
'';
|
||||
|
||||
note_mappings =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.str
|
||||
''
|
||||
{
|
||||
new = "<C-x>";
|
||||
insert_link = "<C-l>";
|
||||
}
|
||||
''
|
||||
''
|
||||
Optional, configure note mappings for the picker. These are the defaults.
|
||||
Not all pickers support all mappings.
|
||||
'';
|
||||
''
|
||||
{
|
||||
new = "<C-x>";
|
||||
insert_link = "<C-l>";
|
||||
}
|
||||
''
|
||||
''
|
||||
Optional, configure note mappings for the picker. These are the defaults.
|
||||
Not all pickers support all mappings.
|
||||
'';
|
||||
|
||||
tag_mappings =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.str
|
||||
''
|
||||
{
|
||||
tag_note = "<C-x>";
|
||||
insert_tag = "<C-l>";
|
||||
}
|
||||
''
|
||||
''
|
||||
Optional, configure tag mappings for the picker. These are the defaults.
|
||||
Not all pickers support all mappings.
|
||||
'';
|
||||
''
|
||||
{
|
||||
tag_note = "<C-x>";
|
||||
insert_tag = "<C-l>";
|
||||
}
|
||||
''
|
||||
''
|
||||
Optional, configure tag mappings for the picker. These are the defaults.
|
||||
Not all pickers support all mappings.
|
||||
'';
|
||||
};
|
||||
|
||||
daily_notes = {
|
||||
|
@ -313,24 +324,40 @@ with lib; {
|
|||
Set to true to force `:ObsidianOpen` to bring the app to the foreground.
|
||||
'';
|
||||
|
||||
sort_by = helpers.defaultNullOpts.mkEnum ["path" "modified" "accessed" "created"] "modified" ''
|
||||
Sort search results by "path", "modified", "accessed", or "created".
|
||||
The recommend value is "modified" and `true` for `sortReversed`, which means, for example,
|
||||
that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time.
|
||||
'';
|
||||
sort_by =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"path"
|
||||
"modified"
|
||||
"accessed"
|
||||
"created"
|
||||
]
|
||||
"modified"
|
||||
''
|
||||
Sort search results by "path", "modified", "accessed", or "created".
|
||||
The recommend value is "modified" and `true` for `sortReversed`, which means, for example,
|
||||
that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time.
|
||||
'';
|
||||
|
||||
sort_reversed = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether search results should be reversed.
|
||||
'';
|
||||
|
||||
open_notes_in = helpers.defaultNullOpts.mkEnumFirstDefault ["current" "vsplit" "hsplit"] ''
|
||||
Determines how certain commands open notes.
|
||||
open_notes_in =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"current"
|
||||
"vsplit"
|
||||
"hsplit"
|
||||
]
|
||||
''
|
||||
Determines how certain commands open notes.
|
||||
|
||||
The valid options are:
|
||||
- "current" (the default) - to always open in the current window
|
||||
- "vsplit" - to open in a vertical split if there's not already a vertical split
|
||||
- "hsplit" - to open in a horizontal split if there's not already a horizontal split
|
||||
'';
|
||||
The valid options are:
|
||||
- "current" (the default) - to always open in the current window
|
||||
- "vsplit" - to open in a vertical split if there's not already a vertical split
|
||||
- "hsplit" - to open in a horizontal split if there's not already a horizontal split
|
||||
'';
|
||||
|
||||
ui = {
|
||||
enable = helpers.defaultNullOpts.mkBool true ''
|
||||
|
@ -343,51 +370,49 @@ with lib; {
|
|||
|
||||
checkboxes =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
attrsOf (
|
||||
submodule {
|
||||
options = {
|
||||
char = mkOption {
|
||||
type = with helpers.nixvimTypes; maybeRaw str;
|
||||
description = "The character to use for this checkbox.";
|
||||
};
|
||||
|
||||
hl_group = mkOption {
|
||||
type = with helpers.nixvimTypes; maybeRaw str;
|
||||
description = "The name of the highlight group to use for this checkbox.";
|
||||
};
|
||||
(
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
char = mkOption {
|
||||
type = with helpers.nixvimTypes; maybeRaw str;
|
||||
description = "The character to use for this checkbox.";
|
||||
};
|
||||
}
|
||||
)
|
||||
)
|
||||
''
|
||||
{
|
||||
" " = {
|
||||
char = "";
|
||||
hl_group = "ObsidianTodo";
|
||||
};
|
||||
"x" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianDone";
|
||||
};
|
||||
">" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianRightArrow";
|
||||
};
|
||||
"~" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianTilde";
|
||||
};
|
||||
}
|
||||
''
|
||||
''
|
||||
Define how various check-boxes are displayed.
|
||||
You can also add more custom ones...
|
||||
|
||||
NOTE: the 'char' value has to be a single character, and the highlight groups are defined
|
||||
in the `ui.hl_groups` option.
|
||||
'';
|
||||
hl_group = mkOption {
|
||||
type = with helpers.nixvimTypes; maybeRaw str;
|
||||
description = "The name of the highlight group to use for this checkbox.";
|
||||
};
|
||||
};
|
||||
})
|
||||
)
|
||||
''
|
||||
{
|
||||
" " = {
|
||||
char = "";
|
||||
hl_group = "ObsidianTodo";
|
||||
};
|
||||
"x" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianDone";
|
||||
};
|
||||
">" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianRightArrow";
|
||||
};
|
||||
"~" = {
|
||||
char = "";
|
||||
hl_group = "ObsidianTilde";
|
||||
};
|
||||
}
|
||||
''
|
||||
''
|
||||
Define how various check-boxes are displayed.
|
||||
You can also add more custom ones...
|
||||
|
||||
NOTE: the 'char' value has to be a single character, and the highlight groups are defined
|
||||
in the `ui.hl_groups` option.
|
||||
'';
|
||||
|
||||
bullets = {
|
||||
char = helpers.defaultNullOpts.mkStr "•" ''
|
||||
|
@ -427,44 +452,40 @@ with lib; {
|
|||
'';
|
||||
};
|
||||
|
||||
hl_groups =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with helpers.nixvimTypes; attrsOf highlight)
|
||||
''
|
||||
{
|
||||
ObsidianTodo = {
|
||||
bold = true;
|
||||
fg = "#f78c6c";
|
||||
};
|
||||
ObsidianDone = {
|
||||
bold = true;
|
||||
fg = "#89ddff";
|
||||
};
|
||||
ObsidianRightArrow = {
|
||||
bold = true;
|
||||
fg = "#f78c6c";
|
||||
};
|
||||
ObsidianTilde = {
|
||||
bold = true;
|
||||
fg = "#ff5370";
|
||||
};
|
||||
ObsidianRefText = {
|
||||
underline = true;
|
||||
fg = "#c792ea";
|
||||
};
|
||||
ObsidianExtLinkIcon = {
|
||||
fg = "#c792ea";
|
||||
};
|
||||
ObsidianTag = {
|
||||
italic = true;
|
||||
fg = "#89ddff";
|
||||
};
|
||||
ObsidianHighlightText = {
|
||||
bg = "#75662e";
|
||||
};
|
||||
}
|
||||
''
|
||||
"Highlight group definitions.";
|
||||
hl_groups = helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; attrsOf highlight) ''
|
||||
{
|
||||
ObsidianTodo = {
|
||||
bold = true;
|
||||
fg = "#f78c6c";
|
||||
};
|
||||
ObsidianDone = {
|
||||
bold = true;
|
||||
fg = "#89ddff";
|
||||
};
|
||||
ObsidianRightArrow = {
|
||||
bold = true;
|
||||
fg = "#f78c6c";
|
||||
};
|
||||
ObsidianTilde = {
|
||||
bold = true;
|
||||
fg = "#ff5370";
|
||||
};
|
||||
ObsidianRefText = {
|
||||
underline = true;
|
||||
fg = "#c792ea";
|
||||
};
|
||||
ObsidianExtLinkIcon = {
|
||||
fg = "#c792ea";
|
||||
};
|
||||
ObsidianTag = {
|
||||
italic = true;
|
||||
fg = "#89ddff";
|
||||
};
|
||||
ObsidianHighlightText = {
|
||||
bg = "#75662e";
|
||||
};
|
||||
}
|
||||
'' "Highlight group definitions.";
|
||||
};
|
||||
|
||||
attachments = {
|
||||
|
@ -478,32 +499,32 @@ with lib; {
|
|||
|
||||
img_text_func =
|
||||
helpers.defaultNullOpts.mkLuaFn
|
||||
''
|
||||
function(client, path)
|
||||
---@type string
|
||||
local link_path
|
||||
local vault_relative_path = client:vault_relative_path(path)
|
||||
if vault_relative_path ~= nil then
|
||||
-- Use relative path if the image is saved in the vault dir.
|
||||
link_path = vault_relative_path
|
||||
else
|
||||
-- Otherwise use the absolute path.
|
||||
link_path = tostring(path)
|
||||
''
|
||||
function(client, path)
|
||||
---@type string
|
||||
local link_path
|
||||
local vault_relative_path = client:vault_relative_path(path)
|
||||
if vault_relative_path ~= nil then
|
||||
-- Use relative path if the image is saved in the vault dir.
|
||||
link_path = vault_relative_path
|
||||
else
|
||||
-- Otherwise use the absolute path.
|
||||
link_path = tostring(path)
|
||||
end
|
||||
local display_name = vim.fs.basename(link_path)
|
||||
return string.format("", display_name, link_path)
|
||||
end
|
||||
local display_name = vim.fs.basename(link_path)
|
||||
return string.format("", display_name, link_path)
|
||||
end
|
||||
''
|
||||
''
|
||||
A function that determines the text to insert in the note when pasting an image.
|
||||
It takes two arguments, the `obsidian.Client` and a plenary `Path` to the image file.
|
||||
''
|
||||
''
|
||||
A function that determines the text to insert in the note when pasting an image.
|
||||
It takes two arguments, the `obsidian.Client` and a plenary `Path` to the image file.
|
||||
|
||||
```lua
|
||||
@param client obsidian.Client
|
||||
@param path Path the absolute path to the image file
|
||||
@return string
|
||||
```
|
||||
'';
|
||||
```lua
|
||||
@param client obsidian.Client
|
||||
@param path Path the absolute path to the image file
|
||||
@return string
|
||||
```
|
||||
'';
|
||||
|
||||
confirm_img_paste = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to prompt for confirmation when pasting an image.
|
||||
|
@ -542,15 +563,21 @@ with lib; {
|
|||
'';
|
||||
};
|
||||
|
||||
yaml_parser = helpers.defaultNullOpts.mkEnumFirstDefault ["native" "yq"] ''
|
||||
Set the YAML parser to use.
|
||||
yaml_parser =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"native"
|
||||
"yq"
|
||||
]
|
||||
''
|
||||
Set the YAML parser to use.
|
||||
|
||||
The valid options are:
|
||||
- "native" - uses a pure Lua parser that's fast but potentially misses some edge cases.
|
||||
- "yq" - uses the command-line tool yq (https://github.com/mikefarah/yq), which is more robust
|
||||
but much slower and needs to be installed separately.
|
||||
The valid options are:
|
||||
- "native" - uses a pure Lua parser that's fast but potentially misses some edge cases.
|
||||
- "yq" - uses the command-line tool yq (https://github.com/mikefarah/yq), which is more robust
|
||||
but much slower and needs to be installed separately.
|
||||
|
||||
In general you should be using the native parser unless you run into a bug with it, in which
|
||||
case you can temporarily switch to the "yq" parser until the bug is fixed.
|
||||
'';
|
||||
In general you should be using the native parser unless you run into a bug with it, in which
|
||||
case you can temporarily switch to the "yq" parser until the bug is fixed.
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue