aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Palamar <palamar@ualberta.ca>2023-07-24 22:16:25 -0600
committerMatěj Cepl <mcepl@cepl.eu>2023-07-25 15:51:38 +0200
commitf1f1ef2cb483f61c12e9627b8f85ae31d496fc1c (patch)
tree7ce9c13133fe754aa2c38c1ff54d308c2c4d8871
parent3ec213b477c380ce1bb05d5b45f42b774fa18c25 (diff)
downloadvis-yank-highlight-f1f1ef2cb483f61c12e9627b8f85ae31d496fc1c.tar.gz
make style and duration configurable
the style definition is the same as a normal vis theme definition.
-rw-r--r--init.lua13
1 files changed, 10 insertions, 3 deletions
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