diff options
| author | TwoFinger <Two-Finger@users.noreply.github.com> | 2018-01-27 19:41:14 +0200 |
|---|---|---|
| committer | TwoFinger <Two-Finger@users.noreply.github.com> | 2018-01-27 20:16:47 +0200 |
| commit | e9aba1387df1a0adf6ad1441f2ce30904fc35951 (patch) | |
| tree | 098b8d3003d40b451a3bcce100cf7b79362c0791 /lua/plugins/complete-filename.lua | |
| parent | 83ac70b7a2dac1e100f1fddb40383c017ddb94cf (diff) | |
| download | vis-e9aba1387df1a0adf6ad1441f2ce30904fc35951.tar.gz vis-e9aba1387df1a0adf6ad1441f2ce30904fc35951.tar.xz | |
vis-complete: send whole paths for completion
text_object_word() was only sending the last part of a pathname to
vis-complete.
text_object_longword() is better, but sometimes may send a bit too much,
so leading delimiters for some languages are stripped additionally.
Diffstat (limited to 'lua/plugins/complete-filename.lua')
| -rw-r--r-- | lua/plugins/complete-filename.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua index cb5b361..ceffdd2 100644 --- a/lua/plugins/complete-filename.lua +++ b/lua/plugins/complete-filename.lua @@ -6,12 +6,15 @@ vis:map(vis.modes.INSERT, "<C-x><C-f>", function() local pos = win.selection.pos if not pos then return end -- TODO do something clever here - local range = file:text_object_word(pos > 0 and pos-1 or pos); + local range = file:text_object_longword(pos > 0 and pos-1 or pos); if not range then return end if range.finish > pos then range.finish = pos end if range.start == range.finish then return end local prefix = file:content(range) if not prefix then return end + -- Strip leading delimiters for some languages + i, j = string.find(prefix, "[[(<'\"]+") + if j then prefix = prefix:sub(j + 1) end local cmd = string.format("vis-complete --file '%s'", prefix:gsub("'", "'\\''")) local status, out, err = vis:pipe(file, { start = 0, finish = 0 }, cmd) if status ~= 0 or not out then |
