dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b9f61fdca5765a5b54f217ae5bdecc0f094d5074
parent 957bdfae2dc2d5ff3fdea329bd5ee40465589b5b
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 27 Jun 2019 10:08:55 +0200

Better autocomplete from current buffer

Diffstat:
M.config/vis/visrc.lua | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -100,11 +100,6 @@ vis.events.subscribe(vis.events.INIT, function() function() vis:feedkeys('o<Escape><Up>') end) vis:map(vis.modes.NORMAL, '[ ', function() vis:feedkeys('O<Escape><Down>') end) - - -- complete from words in current file - vis:map(vis.modes.INSERT, '<C-x><C-n>', - '<Escape>:< cat "$vis_filepath" | vis-complete --word<Enter>') - end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) @@ -115,6 +110,20 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:command('set tabwidth 4') vis:command('set colorcolumn 80') + -- complete from words in current file + vis:map(vis.modes.INSERT, '<C-x><C-n>', + function() + local tmpfile = '/tmp/vis-complete' + local fp = io.popen('vis-complete --word >'..tmpfile, 'w') + fp:write(vis.win.file:content(0, vis.win.file.size)) + fp:close() + local f = io.open(tmpfile, 'r') + local output = f:read() + vis:insert(output) + f:close() + vis:feedkeys("<vis-redraw>") + end) + -- file-type specific commands if vis.win.syntax == 'latex' then vis:command('set colorcolumn 0')