summaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-09 10:07:31 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-09 10:07:31 +0200
commit3c3f2e685589bb028c2aa93e82d1668c393f8e16 (patch)
treec0e99597af7a531701b48f873d8b4f1f54f2bd01 /lua
parent76029787629ec3c6dfb28e3c6769110a092d9a13 (diff)
downloadnvim-config-3c3f2e685589bb028c2aa93e82d1668c393f8e16.tar.gz
nvim-config-3c3f2e685589bb028c2aa93e82d1668c393f8e16.zip
fix(nvim): follow plugin expands env vars for file names
Previously, the target of follow (`<Leader>gg` and related) was applying `vim.fn.fnameescape()` in all cases, including the case when following a file name. However, file names can contain environment variables which are expanded by `:edit` but they are not parsed as environment variables when escaped.
Diffstat (limited to 'lua')
-rw-r--r--lua/dotfiles/follow.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/lua/dotfiles/follow.lua b/lua/dotfiles/follow.lua
index 00e0b9c..51c9972 100644
--- a/lua/dotfiles/follow.lua
+++ b/lua/dotfiles/follow.lua
@@ -107,7 +107,8 @@ end
-- edit-type: edit|split|vsplit
local function edit_target(target, edit_cmd)
local scheme, uri = string.match(target, "^(%a[%w%+%-%.]+)://(.*)")
- if scheme ~= nil then -- if the target is a URL (and not a file name)
+ local target_is_url = scheme ~= nil
+ if target_is_url then
uri = vim.uri_decode(uri)
target = scheme .. "://" .. uri
end
@@ -122,7 +123,10 @@ local function edit_target(target, edit_cmd)
end
target = resolved
end
- vim.cmd(edit_cmd .. " " .. vim.fn.fnameescape(target))
+ if target_is_url then
+ target = vim.fn.fnameescape(target)
+ end
+ vim.cmd(edit_cmd .. " " .. target)
if handler ~= nil and handler.after ~= nil then
handler.after()
end