Skip to content

Commit

Permalink
complete-filename: complete tilda as $HOME as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mcepl authored and rnpnr committed Jan 20, 2025
1 parent e9e0927 commit 4970df0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/plugins/complete-filename.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ local complete_filename = function(expand)
range.finish = pos
end

-- Expand tilda for the home directory
if prefix:find('^~') then
local home = assert(os.getenv("HOME"), "$HOME variable not set!")
prefix = prefix:gsub("^~", home, 1)
end

local cmdfmt = "vis-complete --file '%s'"
if expand then cmdfmt = "vis-open -- '%s'*" end
local status, out, err = vis:pipe(cmdfmt:format(prefix:gsub("'", "'\\''")))
Expand Down

0 comments on commit 4970df0

Please sign in to comment.