diff options
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() |
