From 16e31ceb717c943584cb75d0e28c21e356a54076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Mon, 24 Mar 2025 10:11:05 -0400 Subject: lua/lexers: update to scintillua 6.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an amalgamation of the following upstream commits: - Overhauled API documentation for lexer.lua. - Fixed Markdown to allow code fence blocks to be indented. - Use GitHub Pages' Primer theme for documentation. Build static pages with Jekyll, like GitHub Pages does. - Migrated systemd lexer. Thanks to Matěj Cepl. - Migrated Lisp lexer and highlight character escapes. Thanks to Matěj Cepl. - Migrated rpmspec lexer and made some improvements. Thanks to Matěj Cepl. - Modernized reST lexer. Thanks to Matěj Cepl. - Markdown lexer should just tag the start of a blockquote. The quote's contents may contain markdown. - Output lexer can highlight CSI color sequences. - Allow lexers to define their own fold functions. - Added custom folder for Markdown headers. - Added `lexer.line_start`, `lexer.line_end` and `lexer.text_range()`. - Fixed Markdown lexer to not lex some continuation lines as code. - Fixed SciTE not using Scintillua's markdown lexer. - Markdown lexer should not highlight secondary paragraphs in list items as code blocks. - Have SciTE recognize CMakeLists.txt. --- lua/lexers/output.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lua/lexers/output.lua') diff --git a/lua/lexers/output.lua b/lua/lexers/output.lua index 797ee97..0dd3f38 100644 --- a/lua/lexers/output.lua +++ b/lua/lexers/output.lua @@ -7,7 +7,7 @@ local lexer = lexer local starts_line = lexer.starts_line -local P, S = lpeg.P, lpeg.S +local P, S, R = lpeg.P, lpeg.S, lpeg.R local lex = lexer.new(..., {lex_by_line = true}) @@ -94,6 +94,19 @@ lex:add_rule('perl', starts_line(message((lexer.nonnewline - ' at ')^1)) * text( lex:add_rule('cmake', starts_line(text('CMake Error at ')) * c_filename * colon * line * colon * mark_error) -lex:add_rule('any_line', lex:tag(lexer.DEFAULT, lexer.to_eol())) +-- CSI sequences, including colors. +local csi = P('\x1B[') +local non_csi_seq = text((lexer.nonnewline - csi)^1) +local colors = {'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'} +local csi_color = P(false) +for i, name in ipairs(colors) do + local bold, color = '1;', tostring(30 + i - 1) + csi_color = csi_color + + (lex:tag('csi', csi * bold * color * 'm') * lex:tag('csi.' .. name .. '.bright', non_csi_seq)) + + (lex:tag('csi', csi * color * 'm') * lex:tag('csi.' .. name, non_csi_seq)) +end +local csi_seq = #csi * (csi_color + lex:tag('csi', csi * (lexer.nonnewline - R('@~'))^0 * R('@~'))) + +lex:add_rule('any_line', (non_csi_seq + csi_seq)^1) return lex -- cgit v1.2.3