mirror of
https://github.com/neovim/neovim
synced 2025-07-28 17:32:00 +00:00
feat(lsp.util): remove uneeded do-end
This commit is contained in:
@ -1238,57 +1238,56 @@ function M.stylize_markdown(bufnr, contents, opts)
|
|||||||
local highlights = {} --- @type {ft:string,start:integer,finish:integer}[]
|
local highlights = {} --- @type {ft:string,start:integer,finish:integer}[]
|
||||||
-- keep track of lnums that contain markdown
|
-- keep track of lnums that contain markdown
|
||||||
local markdown_lines = {} --- @type table<integer,boolean>
|
local markdown_lines = {} --- @type table<integer,boolean>
|
||||||
do
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= #contents do
|
while i <= #contents do
|
||||||
local line = contents[i]
|
local line = contents[i]
|
||||||
local match = match_begin(line)
|
local match = match_begin(line)
|
||||||
if match then
|
if match then
|
||||||
local start = #stripped
|
local start = #stripped
|
||||||
i = i + 1
|
i = i + 1
|
||||||
while i <= #contents do
|
while i <= #contents do
|
||||||
line = contents[i]
|
line = contents[i]
|
||||||
if match_end(line, match) then
|
if match_end(line, match) then
|
||||||
i = i + 1
|
|
||||||
break
|
|
||||||
end
|
|
||||||
table.insert(stripped, line)
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
break
|
||||||
end
|
end
|
||||||
table.insert(highlights, {
|
table.insert(stripped, line)
|
||||||
ft = match.ft,
|
|
||||||
start = start + 1,
|
|
||||||
finish = #stripped,
|
|
||||||
})
|
|
||||||
-- add a separator, but not on the last line
|
|
||||||
if opts.separator and i < #contents then
|
|
||||||
table.insert(stripped, '---')
|
|
||||||
markdown_lines[#stripped] = true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- strip any empty lines or separators prior to this separator in actual markdown
|
|
||||||
if line:match('^---+$') then
|
|
||||||
while
|
|
||||||
markdown_lines[#stripped]
|
|
||||||
and (stripped[#stripped]:match('^%s*$') or stripped[#stripped]:match('^---+$'))
|
|
||||||
do
|
|
||||||
markdown_lines[#stripped] = false
|
|
||||||
table.remove(stripped, #stripped)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- add the line if its not an empty line following a separator
|
|
||||||
if
|
|
||||||
not (
|
|
||||||
line:match('^%s*$')
|
|
||||||
and markdown_lines[#stripped]
|
|
||||||
and stripped[#stripped]:match('^---+$')
|
|
||||||
)
|
|
||||||
then
|
|
||||||
table.insert(stripped, line)
|
|
||||||
markdown_lines[#stripped] = true
|
|
||||||
end
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
table.insert(highlights, {
|
||||||
|
ft = match.ft,
|
||||||
|
start = start + 1,
|
||||||
|
finish = #stripped,
|
||||||
|
})
|
||||||
|
-- add a separator, but not on the last line
|
||||||
|
if opts.separator and i < #contents then
|
||||||
|
table.insert(stripped, '---')
|
||||||
|
markdown_lines[#stripped] = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- strip any empty lines or separators prior to this separator in actual markdown
|
||||||
|
if line:match('^---+$') then
|
||||||
|
while
|
||||||
|
markdown_lines[#stripped]
|
||||||
|
and (stripped[#stripped]:match('^%s*$') or stripped[#stripped]:match('^---+$'))
|
||||||
|
do
|
||||||
|
markdown_lines[#stripped] = false
|
||||||
|
table.remove(stripped, #stripped)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- add the line if its not an empty line following a separator
|
||||||
|
if
|
||||||
|
not (
|
||||||
|
line:match('^%s*$')
|
||||||
|
and markdown_lines[#stripped]
|
||||||
|
and stripped[#stripped]:match('^---+$')
|
||||||
|
)
|
||||||
|
then
|
||||||
|
table.insert(stripped, line)
|
||||||
|
markdown_lines[#stripped] = true
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user