aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/man.lua
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-05-09 11:23:51 +0200
committerChristian Clason <c.clason@uni-graz.at>2022-05-09 16:31:55 +0200
commitaefdc6783cb77f09786542c90901a9e7120bea42 (patch)
treeddce6de8f084ab96270f6111d8e423d0b1533171 /runtime/lua/man.lua
parent676e9e9334043ce74af74f85f889b0327a443d0b (diff)
downloadrneovim-aefdc6783cb77f09786542c90901a9e7120bea42.tar.gz
rneovim-aefdc6783cb77f09786542c90901a9e7120bea42.tar.bz2
rneovim-aefdc6783cb77f09786542c90901a9e7120bea42.zip
chore: format runtime with stylua
Diffstat (limited to 'runtime/lua/man.lua')
-rw-r--r--runtime/lua/man.lua28
1 files changed, 14 insertions, 14 deletions
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index ba6b9d09c9..5da3d2a92f 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -8,7 +8,7 @@ local function highlight_line(line, linenr)
local overstrike, escape = false, false
local hls = {} -- Store highlight groups as { attr, start, final }
local NONE, BOLD, UNDERLINE, ITALIC = 0, 1, 2, 3
- local hl_groups = {[BOLD]="manBold", [UNDERLINE]="manUnderline", [ITALIC]="manItalic"}
+ local hl_groups = { [BOLD] = 'manBold', [UNDERLINE] = 'manUnderline', [ITALIC] = 'manItalic' }
local attr = NONE
local byte = 0 -- byte offset
@@ -47,7 +47,7 @@ local function highlight_line(line, linenr)
end
if continue_hl then
- hls[#hls + 1] = {attr=attr, start=byte, final=-1}
+ hls[#hls + 1] = { attr = attr, start = byte, final = -1 }
else
if attr == NONE then
for a, _ in pairs(hl_groups) do
@@ -63,7 +63,7 @@ local function highlight_line(line, linenr)
-- can be represented in one byte. Any code point above that is represented by
-- a leading byte (0xc0 and above) and continuation bytes (0x80 to 0xbf, or
-- decimal 128 to 191).
- for char in line:gmatch("[^\128-\191][\128-\191]*") do
+ for char in line:gmatch('[^\128-\191][\128-\191]*') do
if overstrike then
local last_hl = hls[#hls]
if char == prev_char then
@@ -93,7 +93,7 @@ local function highlight_line(line, linenr)
if last_hl and last_hl.attr == attr and last_hl.final == byte then
last_hl.final = byte + #char
else
- hls[#hls + 1] = {attr=attr, start=byte, final=byte + #char}
+ hls[#hls + 1] = { attr = attr, start = byte, final = byte + #char }
end
overstrike = false
@@ -106,25 +106,25 @@ local function highlight_line(line, linenr)
-- We only want to match against SGR sequences, which consist of ESC
-- followed by '[', then a series of parameter and intermediate bytes in
-- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117)
- local sgr = prev_char:match("^%[([\032-\063]*)m$")
+ local sgr = prev_char:match('^%[([\032-\063]*)m$')
-- Ignore escape sequences with : characters, as specified by ITU's T.416
-- Open Document Architecture and interchange format.
- if sgr and not string.find(sgr, ":") then
+ if sgr and not string.find(sgr, ':') then
local match
while sgr and #sgr > 0 do
-- Match against SGR parameters, which may be separated by ';'
- match, sgr = sgr:match("^(%d*);?(.*)")
+ match, sgr = sgr:match('^(%d*);?(.*)')
add_attr_hl(match + 0) -- coerce to number
end
escape = false
- elseif not prev_char:match("^%[[\032-\063]*$") then
+ elseif not prev_char:match('^%[[\032-\063]*$') then
-- Stop looking if this isn't a partial CSI sequence
escape = false
end
- elseif char == "\027" then
+ elseif char == '\027' then
escape = true
prev_char = ''
- elseif char == "\b" then
+ elseif char == '\b' then
overstrike = true
prev_char = chars[#chars]
byte = byte - #prev_char
@@ -143,7 +143,7 @@ local function highlight_line(line, linenr)
hl_groups[hl.attr],
linenr - 1,
hl.start,
- hl.final
+ hl.final,
}
end
end
@@ -152,8 +152,8 @@ local function highlight_line(line, linenr)
end
local function highlight_man_page()
- local mod = vim.api.nvim_buf_get_option(0, "modifiable")
- vim.api.nvim_buf_set_option(0, "modifiable", true)
+ local mod = vim.api.nvim_buf_get_option(0, 'modifiable')
+ vim.api.nvim_buf_set_option(0, 'modifiable', true)
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for i, line in ipairs(lines) do
@@ -166,7 +166,7 @@ local function highlight_man_page()
end
buf_hls = {}
- vim.api.nvim_buf_set_option(0, "modifiable", mod)
+ vim.api.nvim_buf_set_option(0, 'modifiable', mod)
end
return { highlight_man_page = highlight_man_page }