1
0
Fork 0

.config/vis: implement mode-based cursor styling in personal theme config

main
urosm 2024-08-02 03:29:09 +02:00
parent 5c92109015
commit 6bdbaea817
1 changed files with 37 additions and 0 deletions

View File

@ -1,3 +1,40 @@
-- define additional cursor styles on WIN_OPEN
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
win['STYLE_CURSOR_'..vis.modes.OPERATOR_PENDING] = win.STYLE_LEXER_MAX - 1
win['STYLE_CURSOR_'..vis.modes.VISUAL] = win.STYLE_LEXER_MAX - 2
win['STYLE_CURSOR_'..vis.modes.VISUAL_LINE] = win.STYLE_LEXER_MAX - 3
win['STYLE_CURSOR_'..vis.modes.INSERT] = win.STYLE_LEXER_MAX - 4
win['STYLE_CURSOR_'..vis.modes.REPLACE] = win.STYLE_LEXER_MAX - 5
win:style_define(
win['STYLE_CURSOR_'..vis.modes.OPERATOR_PENDING],
'fore:black,back:red')
win:style_define(
win['STYLE_CURSOR_'..vis.modes.VISUAL],
'fore:black,back:yellow')
win:style_define(
win['STYLE_CURSOR_'..vis.modes.VISUAL_LINE],
'fore:black,back:yellow')
win:style_define(
win['STYLE_CURSOR_'..vis.modes.INSERT],
'fore:black,back:magenta')
win:style_define(
win['STYLE_CURSOR_'..vis.modes.REPLACE],
'fore:black,back:green')
end)
-- apply additional cursor styles on WIN_STATUS
vis.events.subscribe(vis.events.WIN_STATUS, function(win)
local pos = win.selection.pos
win:style(win['STYLE_CURSOR'], pos, pos)
if win == vis.win then
local mode_style_id =
win['STYLE_CURSOR_'..vis.mode] or
win['STYLE_CURSOR_PRIMARY']
win:style(mode_style_id, pos, pos)
end
end)
local lexers = vis.lexers
lexers.STYLE_LINENUMBER = 'fore:blue'
lexers.STYLE_LINENUMBER_CURSOR = 'fore:magenta'