diff options
author | Randy Palamar <palamar@ualberta.ca> | 2023-07-24 22:16:25 -0600 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2023-07-25 15:51:38 +0200 |
commit | f1f1ef2cb483f61c12e9627b8f85ae31d496fc1c (patch) | |
tree | 7ce9c13133fe754aa2c38c1ff54d308c2c4d8871 /init.lua | |
parent | 3ec213b477c380ce1bb05d5b45f42b774fa18c25 (diff) | |
download | vis-yank-highlight-f1f1ef2cb483f61c12e9627b8f85ae31d496fc1c.tar.gz |
make style and duration configurable
the style definition is the same as a normal vis theme definition.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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 |