diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-24 16:54:10 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-24 17:02:52 +0200 |
| commit | 42233850cef2e1b30dc6524e056f604c3b5d021b (patch) | |
| tree | 142a706725ebafa20a30603ee6eca546ddb84723 /plugin/50-notes.lua | |
| parent | 6d35e81f1bfdae7da7e98eea850e5f6c7741ece8 (diff) | |
| download | nvim-config-42233850cef2e1b30dc6524e056f604c3b5d021b.tar.gz nvim-config-42233850cef2e1b30dc6524e056f604c3b5d021b.zip | |
refactor(nvim): rewrite goto plugin (now called follow)
`lua/dotfiles/follow.lua` provides an engine to register "followable
entities" like URL, wiki-links etc and can be easily expanded.
The engine provides a function to navigate between followable entities
and a function to edit them inside neovim.
Diffstat (limited to 'plugin/50-notes.lua')
| -rw-r--r-- | plugin/50-notes.lua | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/plugin/50-notes.lua b/plugin/50-notes.lua index 30c655c..4e0494c 100644 --- a/plugin/50-notes.lua +++ b/plugin/50-notes.lua @@ -23,7 +23,7 @@ -- `<Leader>nn`: fuzzy-find notes by tags -- `<Leader>nf`: fuzzy-find notes by file name -- `<Leader>ng`: fuzzy-find notes by content --- `<Tab>` / `<S-Tab>` (in notes buffers): go to next/previous URL or wiki-link +-- `<Tab>` / `<S-Tab>` (in notes buffers): go to next/previous followable entity -- if vim.env.NOTES_DIR == nil then @@ -33,8 +33,10 @@ end local notes_dir = vim.fs.normalize(vim.env.NOTES_DIR) local tagfile = vim.fs.joinpath(vim.fn.stdpath("state"), "notes-tags") +local follow = require("dotfiles.follow") + ---------------------------------------------------------------------------------------------------- --- Tags --------------------------------------------------------------------------------------------- +-- Tags -------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- -- Generates ctags for (markdown) files in `notes_dir` @@ -417,36 +419,24 @@ local function rename_section_command(opts) end ---------------------------------------------------------------------------------------------------- --- Navigation -------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- - --- Moves the cursor to the start of the next (or previous, when `backward`) URL or `[[wiki-link]]`, --- wrapping around the buffer. "URL" means a `scheme://…` target, matching the follow engine in --- 50-goto.lua. -local function goto_url(backward) - local pattern = [[\v(\a[0-9A-Za-z+.-]*://\S+|\[\[.{-}\]\])]] - vim.fn.search(pattern, backward and "bw" or "w") -end - ----------------------------------------------------------------------------------------------------- -- Buffer init & pickers --------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- -- Initializes a notes buffer -- * Include generated notes tags in 'tags' option -- * Enable wikilink completion --- * Map <Tab>/<S-Tab> to jump between URLs/wiki-links +-- * Map <Tab>/<S-Tab> to jump between followable entities local function init_notes_buffer() if not vim.tbl_contains(vim.opt_local.tags:get(), tagfile) then vim.opt_local.tags:append(tagfile) end vim.bo.omnifunc = "v:lua.dotfiles_wikilink_source" vim.keymap.set("n", "<Tab>", function() - goto_url(false) - end, { buffer = true, desc = "Go to next URL/wiki-link" }) + follow.next(false) + end, { buffer = true, desc = "Go to next followable entity" }) vim.keymap.set("n", "<S-Tab>", function() - goto_url(true) - end, { buffer = true, desc = "Go to previous URL/wiki-link" }) + follow.next(true) + end, { buffer = true, desc = "Go to previous followable entity" }) end local function find_notes_by_tag() |
