diff options
Diffstat (limited to '.config')
| -rw-r--r-- | .config/nvim/lua/dotfiles/follow.lua | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/.config/nvim/lua/dotfiles/follow.lua b/.config/nvim/lua/dotfiles/follow.lua index 5a3962c..00e0b9c 100644 --- a/.config/nvim/lua/dotfiles/follow.lua +++ b/.config/nvim/lua/dotfiles/follow.lua @@ -1,18 +1,16 @@ --- Generic "follow the thing under the cursor" engine: extracts a target (a --- markdown link, `<cfile>`, or the visual selection), parses an optional --- `scheme://uri`, and opens it. Features register per-scheme resolvers and --- pre-target follow handlers (e.g. wiki-links) so this file stays --- scheme-agnostic — see 50-notes.lua and 50-nvim-help.lua. +-- Generic "follow the thing under the cursor" engine: extracts a target (a markdown link, `<cfile>`, or the visual +-- selection), parses an optional `scheme://uri`, and opens it. Features register per-scheme resolvers and pre-target +-- follow handlers (e.g. wiki-links) so this file stays scheme-agnostic — see 50-notes.lua and 50-nvim-help.lua. local M = {} -- scheme name -> { resolve = fun(uri): target|nil, err?, after = fun()? } --- resolve maps the decoded uri to a path to edit; returning nil aborts (with --- an optional message). after, if present, runs in the freshly-opened buffer. +-- resolve maps the decoded uri to a path to edit; returning nil aborts (with an optional message). after, if present, +-- runs in the freshly-opened buffer. local scheme_handlers = {} --- Follow handlers that get first crack before generic target extraction. Each is --- fun(edit_cmd): handled(boolean), tried in registration order. +-- Follow handlers that get first crack before generic target extraction. Each is fun(edit_cmd): handled(boolean), tried +-- in registration order. local follow_handlers = {} -- Register a `scheme://` resolver. See `scheme_handlers` for the handler shape. @@ -130,8 +128,7 @@ local function edit_target(target, edit_cmd) end end --- Follow a registered handler (e.g. a wiki-link) if one claims the cursor, else --- fall back to generic URL/file following. +-- Follow a registered handler (e.g. a wiki-link) if one claims the cursor else fall back to generic URL/file following. function M.follow(edit_cmd) for _, fn in ipairs(follow_handlers) do if fn(edit_cmd) then |
