summaryrefslogtreecommitdiffstats
path: root/.config/nvim/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
commitc1ef3991107048a246199d8f549c84ec4fb51c58 (patch)
treea706d9762a50d277420ad68b4176e93b327571ab /.config/nvim/lua
parent649c0c6889a9929be346031b6074c0eac3531a91 (diff)
downloaddotfiles-c1ef3991107048a246199d8f549c84ec4fb51c58.tar.gz
dotfiles-c1ef3991107048a246199d8f549c84ec4fb51c58.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 '.config/nvim/lua')
-rw-r--r--.config/nvim/lua/dotfiles/follow.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/.config/nvim/lua/dotfiles/follow.lua b/.config/nvim/lua/dotfiles/follow.lua
index 00e0b9c..51c9972 100644
--- a/.config/nvim/lua/dotfiles/follow.lua
+++ b/.config/nvim/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