aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2025-01-19 17:34:09 +0100
committerRandy Palamar <randy@rnpnr.xyz>2025-01-19 21:10:55 -0700
commit4970df09cea1e427b36469cc66340906cb5a0cb1 (patch)
treed559d4d1806ef03cfeed9edcaad46bdb02a7fdda /lua/plugins
parente9e0927c8abc0be73e3bb2642defb28d0f065ab4 (diff)
downloadvis-4970df09cea1e427b36469cc66340906cb5a0cb1.tar.gz
vis-4970df09cea1e427b36469cc66340906cb5a0cb1.tar.xz
complete-filename: complete tilda as $HOME as well
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/complete-filename.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua
index 43cf14b..02b9f3a 100644
--- a/lua/plugins/complete-filename.lua
+++ b/lua/plugins/complete-filename.lua
@@ -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("'", "'\\''")))