mirror of
https://github.com/neovim/neovim.git
synced 2026-02-21 09:50:19 +10:00
chore: format runtime with stylua
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user