aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/complete-filename.lua
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-07-12 19:05:03 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-07-14 11:45:15 +0200
commit386eac2063bdda79279bbdea2fffcd7fc0ff682a (patch)
tree73ef16bc7f07ba8848020b98be3cde123f5b0a36 /lua/plugins/complete-filename.lua
parent546917d21ca10214c24d3871c92b81265de6958c (diff)
downloadvis-386eac2063bdda79279bbdea2fffcd7fc0ff682a.tar.gz
vis-386eac2063bdda79279bbdea2fffcd7fc0ff682a.tar.xz
vis-lua: make selection first class primitives in Lua API
Diffstat (limited to 'lua/plugins/complete-filename.lua')
-rw-r--r--lua/plugins/complete-filename.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua
index 3648efe..cb5b361 100644
--- a/lua/plugins/complete-filename.lua
+++ b/lua/plugins/complete-filename.lua
@@ -1,9 +1,9 @@
--- complete file path at primary cursor location using vis-complete(1)
+-- complete file path at primary selection location using vis-complete(1)
vis:map(vis.modes.INSERT, "<C-x><C-f>", function()
local win = vis.win
local file = win.file
- local pos = win.cursor.pos
+ 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);
@@ -19,15 +19,15 @@ vis:map(vis.modes.INSERT, "<C-x><C-f>", function()
return
end
file:insert(pos, out)
- win.cursor.pos = pos + #out
+ win.selection.pos = pos + #out
end, "Complete file path")
--- complete file path at primary cursor location using vis-open(1)
+-- complete file path at primary selection location using vis-open(1)
vis:map(vis.modes.INSERT, "<C-x><C-o>", function()
local win = vis.win
local file = win.file
- local pos = win.cursor.pos
+ local pos = win.selection.pos
if not pos then return end
local range = file:text_object_word(pos > 0 and pos-1 or pos);
if not range then return end
@@ -48,5 +48,5 @@ vis:map(vis.modes.INSERT, "<C-x><C-o>", function()
out = out:gsub("\n$", "")
file:delete(range)
file:insert(range.start, out)
- win.cursor.pos = range.start + #out
+ win.selection.pos = range.start + #out
end, "Complete file name")