1
0
Fork 0
dot/.config/vis/visrc.lua

88 lines
2.6 KiB
Lua
Raw Normal View History

2024-07-31 12:05:39 +02:00
require('vis')
local mode_strings = {
[vis.modes.NORMAL] = 'NORMAL',
[vis.modes.OPERATOR_PENDING] = 'OPERATOR-PENDING',
[vis.modes.VISUAL] = 'VISUAL',
[vis.modes.VISUAL_LINE] = 'VISUAL-LINE',
[vis.modes.INSERT] = 'INSERT',
[vis.modes.REPLACE] = 'REPLACE',
}
-- editor options
2024-07-31 12:05:39 +02:00
vis.events.subscribe(vis.events.INIT, function()
vis.options.theme = require("themes.basic")
vis:map(vis.modes.NORMAL, 'y', '<vis-register>+<vis-operator-yank>')
vis:map(vis.modes.VISUAL, 'y', '<vis-register>+<vis-operator-yank>')
vis:map(vis.modes.NORMAL, 'y', '<vis-register>+<vis-operator-yank>')
vis:map(vis.modes.VISUAL, 'd', '<vis-register>+<vis-operator-delete>')
vis:map(vis.modes.VISUAL_LINE, 'd', '<vis-register>+<vis-operator-delete>')
vis:map(vis.modes.VISUAL_LINE, 'd', '<vis-register>+<vis-operator-delete>')
vis:map(vis.modes.NORMAL, 'p', '<vis-register>+<vis-put-after>')
vis:map(vis.modes.VISUAL, 'p', '<vis-register>+<vis-put-after>')
vis:map(vis.modes.VISUAL_LINE, 'p', '<vis-register>+<vis-put-after>')
vis:map(vis.modes.NORMAL, 'P', '<vis-register>+<vis-put-before>')
vis:map(vis.modes.VISUAL, 'P', '<vis-register>+<vis-put-before>')
vis:map(vis.modes.VISUAL_LINE, 'P', '<vis-register>+<vis-put-before>')
vis.options.autoindent = true
vis.options.ignorecase = true
end)
-- window options
2024-07-31 12:05:39 +02:00
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
win.options.colorcolumn = 81
win.options.relativenumbers = true
if win.syntax == 'markdown' then
win.options.breakat = " .])}_"
win.options.expandtab = true
win.options.tabwidth = 2
win.options.wrapcolumn = 81
end
end)
2024-07-31 12:05:39 +02:00
vis.events.subscribe(vis.events.WIN_STATUS, function(win)
set_statusline(win, mode_strings[vis.mode])
end)
function set_statusline(win, mode_string)
2024-07-31 12:05:39 +02:00
local left_parts = {}
local right_parts = {}
local file = win.file
local selection = win.selection
local file_info = (file.name or '[No Name]')..(file.modified and '[+]' or '')
if vis.win == win then
-- mode
table.insert(left_parts, mode_string)
2024-07-31 12:05:39 +02:00
-- selection
table.insert(left_parts, selection.number..'/'..#win.selections)
-- file info
file_info =
file_info
..':'
..(vis.count or '')
..(vis.input_queue or '')
..(vis.recording and '@' or '')
-- character under cursor
table.insert(right_parts,
'<'
..(string.byte(file:content(selection.pos, 1)) or '0')
..'>')
end
table.insert(left_parts, file_info)
-- line and column count
table.insert(right_parts, #file.lines..'/'..selection.line)
table.insert(right_parts, selection.col)
win:status(table.concat(left_parts, " "), table.concat(right_parts, " "));
end