diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2025-01-19 17:34:09 +0100 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-19 21:10:55 -0700 |
| commit | 4970df09cea1e427b36469cc66340906cb5a0cb1 (patch) | |
| tree | d559d4d1806ef03cfeed9edcaad46bdb02a7fdda | |
| parent | e9e0927c8abc0be73e3bb2642defb28d0f065ab4 (diff) | |
| download | vis-4970df09cea1e427b36469cc66340906cb5a0cb1.tar.gz vis-4970df09cea1e427b36469cc66340906cb5a0cb1.tar.xz | |
complete-filename: complete tilda as $HOME as well
| -rw-r--r-- | lua/plugins/complete-filename.lua | 6 |
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("'", "'\\''"))) |
