From 4970df09cea1e427b36469cc66340906cb5a0cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Sun, 19 Jan 2025 17:34:09 +0100 Subject: complete-filename: complete tilda as $HOME as well --- lua/plugins/complete-filename.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lua') 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("'", "'\\''"))) -- cgit v1.2.3