diff options
author | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
commit | 308e1940dcd64aa6c344c403d4f9e0dda58d9c5c (patch) | |
tree | 35fe43e01755e0f312650667004487a44d6b7941 /runtime/lua/man.lua | |
parent | 96a00c7c588b2f38a2424aeeb4ea3581d370bf2d (diff) | |
parent | e8c94697bcbe23a5c7b07c292b90a6b70aadfa87 (diff) | |
download | rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.gz rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.bz2 rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.zip |
Merge remote-tracking branch 'upstream/master' into rahm
Diffstat (limited to 'runtime/lua/man.lua')
-rw-r--r-- | runtime/lua/man.lua | 28 |
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 } |