summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-24 17:58:03 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-24 17:58:27 +0200
commitbc17346650fd043a72045d0be6141aa832336233 (patch)
treecf8753caf078372112e66851787b9978458103d2 /plugin
parent8e18ba3557df6fb71ce0b31a8984fe0361bad070 (diff)
downloadnvim-config-bc17346650fd043a72045d0be6141aa832336233.tar.gz
nvim-config-bc17346650fd043a72045d0be6141aa832336233.zip
refactor(nvim): group all follow registrations into one section
Diffstat (limited to 'plugin')
-rw-r--r--plugin/50-follow.lua62
1 files changed, 33 insertions, 29 deletions
diff --git a/plugin/50-follow.lua b/plugin/50-follow.lua
index 8a7fb62..e8ed3a6 100644
--- a/plugin/50-follow.lua
+++ b/plugin/50-follow.lua
@@ -1,10 +1,10 @@
--
-- 50-follow.lua
--
--- Wires the follow engine (lua/dotfiles/follow.lua): registers the followable entities (in the
--- order they are tried, first match wins) and the `notes://` / `nvim-help://` schemes, then maps
--- the gf-family keys to "open the entity under the cursor" and `]u` / `[u` to cycle between
--- entities.
+-- Wires the follow engine (lua/dotfiles/follow.lua): defines the followable entities and the
+-- `notes://` / `nvim-help://` schemes, registers them all (in the order they are tried, first match
+-- wins), then maps the gf-family keys to "open the entity under the cursor" and `]u` / `[u`
+-- to cycle between entities.
--
-- Keymaps:
-- `gf` follow the entity under the cursor in the current window
@@ -72,15 +72,6 @@ local function open_wikilink(edit_cmd, inner)
end
end
-if notes_dir ~= nil then
- df.register("wikilink", wikilink_matches, open_wikilink)
-else
- vim.notify(
- "50-follow.lua: NOTES_DIR is not set, wiki-link following disabled",
- vim.log.levels.WARN
- )
-end
-
----------------------------------------------------------------------------------------------------
-- Markdown links ----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
@@ -155,8 +146,6 @@ local function markdown_link_matches()
return { { from = { c[1], c[2] }, to = { c[1], c[2] + 1 }, target = dest } }
end
-df.register("markdown-link", markdown_link_matches, df.open)
-
----------------------------------------------------------------------------------------------------
-- URLs --------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
@@ -178,8 +167,6 @@ local function url_matches()
return out
end
-df.register("url", url_matches, df.open)
-
----------------------------------------------------------------------------------------------------
-- <cfile> fallback --------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
@@ -204,23 +191,19 @@ local function open_cfile(edit_cmd, _)
vim.api.nvim_feedkeys(builtin_gf[edit_cmd], "nx", false)
end
-df.register("cfile", cfile_matches, open_cfile)
-
----------------------------------------------------------------------------------------------------
-- Schemes -----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--- `notes://<path>` resolves to `<path>` relative to the notes dir (only when $NOTES_DIR is set).
-if notes_dir ~= nil then
- df.register_scheme("notes", {
- resolve = function(uri)
- return notes_dir .. "/" .. uri
- end,
- })
-end
+-- `notes://<path>` resolves to `<path>` relative to the notes dir.
+local notes_scheme = {
+ resolve = function(uri)
+ return notes_dir .. "/" .. uri
+ end,
+}
-- `nvim-help://<tag>` — open Neovim help for <tag> in a scratch, read-only buffer.
-df.register_scheme("nvim-help", {
+local nvim_help_scheme = {
resolve = function(uri)
local tagfiles = {}
for _, path in pairs(vim.opt.runtimepath:get()) do
@@ -239,7 +222,28 @@ df.register_scheme("nvim-help", {
vim.opt_local.swapfile = false
vim.opt_local.readonly = true
end,
-})
+}
+
+----------------------------------------------------------------------------------------------------
+-- Registration ------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
+
+-- Entities are tried in registration order, first match wins; `<cfile>` registers last so `gf`
+-- falls back to Vim's built-in behavior. The wiki-link entity and `notes://` scheme need
+-- $NOTES_DIR.
+if notes_dir ~= nil then
+ df.register("wikilink", wikilink_matches, open_wikilink)
+ df.register_scheme("notes", notes_scheme)
+else
+ vim.notify(
+ "50-follow.lua: NOTES_DIR is not set, wiki-link following disabled",
+ vim.log.levels.WARN
+ )
+end
+df.register("markdown-link", markdown_link_matches, df.open)
+df.register("url", url_matches, df.open)
+df.register("cfile", cfile_matches, open_cfile)
+df.register_scheme("nvim-help", nvim_help_scheme)
----------------------------------------------------------------------------------------------------
-- Keymaps -----------------------------------------------------------------------------------------