From f1f1ef2cb483f61c12e9627b8f85ae31d496fc1c Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Mon, 24 Jul 2023 22:16:25 -0600 Subject: make style and duration configurable the style definition is the same as a normal vis theme definition. --- init.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index df67bb0..142a5c8 100644 --- a/init.lua +++ b/init.lua @@ -1,15 +1,22 @@ require("vis") +local M = { + style = "reverse", -- Style used for highlighting + duration = 0.5, -- [s] Time to remain highlighted (10 ms precision) +} + vis.events.subscribe(vis.events.INIT, function() local yank = vis:action_register("highlighted-yank", function() - vis.win:style_define(vis.win.STYLE_SELECTION, "reverse") + vis.win:style_define(vis.win.STYLE_SELECTION, M.style) vis:redraw() local tstamp = os.clock() - while os.clock() - tstamp < 0.5 do end + while os.clock() - tstamp < M.duration do end vis.win:style_define(vis.win.STYLE_SELECTION, vis.lexers.STYLE_SELECTION) vis:redraw() end, "Yank operator with highlighting") vis:map(vis.modes.OPERATOR_PENDING, "y", yank) vis:map(vis.modes.VISUAL, "y", yank) vis:map(vis.modes.VISUAL_LINE, "y", yank) -end) \ No newline at end of file +end) + +return M -- cgit