~mcepl/vis-yank-highlight

3ec213b477c380ce1bb05d5b45f42b774fa18c25 — Matěj Cepl 7 months ago
Initial commit
3 files changed, 46 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A init.lua
A  => LICENSE +21 -0
@@ 1,21 @@
MIT License

Copyright (c) 2020 Matěj Cepl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => README.md +10 -0
@@ 1,10 @@
Make the yanked region apparent!
================================

Code suggested by Randy Palamar on https://github.com/martanne/vis/issues/1062.

All issues, questions, complaints, or (even better!) patches
should be send via email to
[~mcepl/devel@lists.sr.ht](mailto:~mcepl/devel@lists.sr.ht) email
list (for patches use [git send-email](https://git-send-email.io/)).


A  => init.lua +15 -0
@@ 1,15 @@
require("vis")

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:redraw()
		local tstamp = os.clock()
		while os.clock() - tstamp < 0.5 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