From 386eac2063bdda79279bbdea2fffcd7fc0ff682a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 12 Jul 2017 19:05:03 +0200 Subject: vis-lua: make selection first class primitives in Lua API --- lua/plugins/complete-filename.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lua/plugins/complete-filename.lua') 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, "", 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, "", 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, "", 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, "", 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") -- cgit v1.2.3