general cleanup

This commit is contained in:
Felix Van der Jeugt 2024-07-24 08:35:41 +02:00
parent ffced8fca4
commit 3ffb35cc2e
No known key found for this signature in database
GPG key ID: 58B209295023754D
25 changed files with 149 additions and 120 deletions

View file

@ -40,25 +40,25 @@ local hr = token('hr', lpeg.Cmt(l.starts_line(S(' \t')^0 * lpeg.C(S('*-_'))),
end))
-- Span elements.
local dq_str = token(l.STRING, l.delimited_range('"', false, true))
local sq_str = token(l.STRING, l.delimited_range("'", false, true))
local paren_str = token(l.STRING, l.delimited_range('()'))
local link = token('link', P('!')^-1 * l.delimited_range('[]') *
local dq_str = token(l.STRING, l.range('"', false, true))
local sq_str = token(l.STRING, l.range("'", false, true))
local paren_str = token(l.STRING, l.range('()'))
local link = token('link', P('!')^-1 * l.range('[]') *
(P('(') * (l.any - S(') \t'))^0 *
(S(' \t')^1 *
l.delimited_range('"', false, true))^-1 * ')' +
S(' \t')^0 * l.delimited_range('[]')) +
l.range('"', false, true))^-1 * ')' +
S(' \t')^0 * l.range('[]')) +
P('http://') * (l.any - l.space)^1)
local link_label = token('link_label', l.delimited_range('[]') * ':') * ws *
local link_label = token('link_label', l.range('[]') * ':') * ws *
token('link_url', (l.any - l.space)^1) *
(ws * (dq_str + sq_str + paren_str))^-1
local strong = token('strong', (P('**') * (l.any - '**')^0 * P('**')^-1) +
(P('__') * (l.any - '__')^0 * P('__')^-1))
local em = token('em',
l.delimited_range('*', true) + l.delimited_range('_', true))
l.range('*', true) + l.range('_', true))
local code = token('code', (P('``') * (l.any - '``')^0 * P('``')^-1) +
l.delimited_range('`', true, true))
l.range('`', true, true))
local escape = token(l.DEFAULT, P('\\') * 1)

View file

@ -21,6 +21,13 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win)
vis:command('set number')
end)
vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
if file.size ~= 0 and file:content(file.size - 1, 1) ~= "\n" then
file:insert(file.size, "\n")
end
return true
end)
vis:map(vis.modes.NORMAL, ";;", "<vis-window-next>")
--------------------------------------------------------------------------------
@ -34,6 +41,15 @@ vis:map(vis.modes.NORMAL, "<Escape>", function()
end
end)
--------------------------------------------------------------------------------
-- Fancy cd
vis:command_register("rcd", function(argv, force, cur_win, selection, range)
handle = io.popen('f=$(mktemp); st -e ranger --choosedir="$f" --show-only-dirs; cat "$f"')
local output = handle:read()
handle:close()
vis:command('cd '..output)
end)
--------------------------------------------------------------------------------
-- Fuzzy search filenames to open files