From c1ef3991107048a246199d8f549c84ec4fb51c58 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Tue, 9 Jun 2026 10:07:31 +0200 Subject: fix(nvim): follow plugin expands env vars for file names Previously, the target of follow (`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. --- .config/nvim/lua/dotfiles/follow.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to '.config/nvim') 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 -- cgit v1.3.1