summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/50-notes.lua
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-12 17:02:54 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-12 22:57:34 +0200
commit1734929edd6ceb47fcee53cb9d0a408b41dea14a (patch)
tree2bd06885ddd5f91656dfb7851ddb3446e6a2ca74 /.config/nvim/plugin/50-notes.lua
parentc3c0fe51524d0e7bbc2d93fb9ee0127db691287a (diff)
downloaddotfiles-1734929edd6ceb47fcee53cb9d0a408b41dea14a.tar.gz
dotfiles-1734929edd6ceb47fcee53cb9d0a408b41dea14a.zip
misc(nvim): reformat lua files to 100 char line width
Diffstat (limited to '.config/nvim/plugin/50-notes.lua')
-rw-r--r--.config/nvim/plugin/50-notes.lua59
1 files changed, 46 insertions, 13 deletions
diff --git a/.config/nvim/plugin/50-notes.lua b/.config/nvim/plugin/50-notes.lua
index 907a2bf..4dda9f4 100644
--- a/.config/nvim/plugin/50-notes.lua
+++ b/.config/nvim/plugin/50-notes.lua
@@ -2,13 +2,22 @@ if vim.env.NOTES_DIR == nil then
vim.notify("NOTES_DIR is not set", vim.log.levels.ERROR)
return
end
-vim.g.notes_dir = vim.env.NOTES_DIR:sub(-1) == "/" and vim.env.NOTES_DIR:sub(1, -2) or vim.env.NOTES_DIR
+vim.g.notes_dir = vim.env.NOTES_DIR:sub(-1) == "/" and vim.env.NOTES_DIR:sub(1, -2)
+ or vim.env.NOTES_DIR
local notes_dir = vim.g.notes_dir
local tagfile = vim.fs.joinpath(vim.fn.stdpath("state"), "notes-tags")
local function generate_tags()
- vim.system({ "ctags", "--languages=Markdown", "--tag-relative=no", "--recurse", "-f", tagfile, notes_dir })
+ vim.system({
+ "ctags",
+ "--languages=Markdown",
+ "--tag-relative=no",
+ "--recurse",
+ "-f",
+ tagfile,
+ notes_dir,
+ })
end
-- Completion of all `*.md` note names (relative to the notes dir, extension stripped).
@@ -171,7 +180,13 @@ local function update_all_notes(rewriter)
local new_text
new_text, n = rewriter(text)
if n > 0 then
- vim.api.nvim_buf_set_lines(b, 0, -1, false, vim.split(new_text, "\n", { plain = true }))
+ vim.api.nvim_buf_set_lines(
+ b,
+ 0,
+ -1,
+ false,
+ vim.split(new_text, "\n", { plain = true })
+ )
if not was_modified then -- buffer matched disk; keep it that way
vim.api.nvim_buf_call(b, function()
vim.cmd("silent! write!")
@@ -248,18 +263,28 @@ local function rename_current_note(new_rel)
end)
generate_tags()
- vim.notify(string.format("Renamed to %s — updated %d link(s) in %d file(s)", new_rel, link_count, file_count))
+ vim.notify(
+ string.format(
+ "Renamed to %s — updated %d link(s) in %d file(s)",
+ new_rel,
+ link_count,
+ file_count
+ )
+ )
end
vim.api.nvim_create_user_command("NotesRename", function(opts)
if opts.args ~= "" then
rename_current_note(opts.args)
else
- vim.ui.input({ prompt = "Rename note to: ", default = note_name(vim.api.nvim_buf_get_name(0)) }, function(input)
- if input and input ~= "" then
- rename_current_note(input)
+ vim.ui.input(
+ { prompt = "Rename note to: ", default = note_name(vim.api.nvim_buf_get_name(0)) },
+ function(input)
+ if input and input ~= "" then
+ rename_current_note(input)
+ end
end
- end)
+ )
end
end, { nargs = "?", desc = "Rename current note and update wiki-links" })
@@ -320,7 +345,12 @@ local function rename_current_section(new_head)
generate_tags()
vim.notify(
- string.format("Renamed section to %s — updated %d link(s) in %d file(s)", new_head, link_count, file_count)
+ string.format(
+ "Renamed section to %s — updated %d link(s) in %d file(s)",
+ new_head,
+ link_count,
+ file_count
+ )
)
end
@@ -329,11 +359,14 @@ vim.api.nvim_create_user_command("NotesRenameSection", function(opts)
rename_current_section(opts.args)
else
local heading = heading_at_cursor(vim.api.nvim_get_current_buf())
- vim.ui.input({ prompt = "Rename section to: ", default = heading and heading.text }, function(input)
- if input and input ~= "" then
- rename_current_section(input)
+ vim.ui.input(
+ { prompt = "Rename section to: ", default = heading and heading.text },
+ function(input)
+ if input and input ~= "" then
+ rename_current_section(input)
+ end
end
- end)
+ )
end
end, { nargs = "*", desc = "Rename the heading at the cursor and update wiki-links" })