From 7e647657b0f95a4756b8aa714b0b3e4295272b81 Mon Sep 17 00:00:00 2001
From: mitchell
Date: Mon, 3 Aug 2020 18:48:30 -0400
Subject: lexlua: Deprecated `lexer.fold_line_comments()` in favor of
`lexer.fold_consecutive_lines()`. Also use `lexer.fold_line_groups` for
option that enables this folding, avoiding name clash that plagued the
previous option. Added "import" folding for Java.
---
doc/LPegLexer.html | 27 +++++++++++++--------------
doc/ScintillaHistory.html | 8 ++++++++
lexlua/actionscript.lua | 2 +-
lexlua/ansi_c.lua | 2 +-
lexlua/antlr.lua | 2 +-
lexlua/apdl.lua | 2 +-
lexlua/asm.lua | 2 +-
lexlua/awk.lua | 2 +-
lexlua/bash.lua | 2 +-
lexlua/cmake.lua | 2 +-
lexlua/context.lua | 2 +-
lexlua/cpp.lua | 2 +-
lexlua/crystal.lua | 2 +-
lexlua/csharp.lua | 2 +-
lexlua/dart.lua | 2 +-
lexlua/dot.lua | 2 +-
lexlua/eiffel.lua | 2 +-
lexlua/erlang.lua | 2 +-
lexlua/gap.lua | 2 +-
lexlua/go.lua | 2 +-
lexlua/groovy.lua | 2 +-
lexlua/gtkrc.lua | 2 +-
lexlua/icon.lua | 2 +-
lexlua/io_lang.lua | 2 +-
lexlua/java.lua | 3 ++-
lexlua/javascript.lua | 2 +-
lexlua/json.lua | 2 +-
lexlua/latex.lua | 2 +-
lexlua/less.lua | 2 +-
lexlua/lexer.lua | 46 +++++++++++++++++++++++++++++++---------------
lexlua/lisp.lua | 2 +-
lexlua/lua.lua | 2 +-
lexlua/matlab.lua | 4 ++--
lexlua/nemerle.lua | 2 +-
lexlua/objective_c.lua | 2 +-
lexlua/perl.lua | 2 +-
lexlua/php.lua | 4 ++--
lexlua/pike.lua | 2 +-
lexlua/pkgbuild.lua | 2 +-
lexlua/rc.lua | 2 +-
lexlua/rebol.lua | 2 +-
lexlua/rexx.lua | 2 +-
lexlua/ruby.lua | 2 +-
lexlua/rust.lua | 2 +-
lexlua/sass.lua | 2 +-
lexlua/scala.lua | 2 +-
lexlua/scheme.lua | 2 +-
lexlua/tcl.lua | 2 +-
lexlua/template.txt | 2 +-
lexlua/tex.lua | 2 +-
lexlua/vala.lua | 2 +-
lexlua/verilog.lua | 2 +-
lexlua/xtend.lua | 4 ++--
53 files changed, 106 insertions(+), 82 deletions(-)
diff --git a/doc/LPegLexer.html b/doc/LPegLexer.html
index 2926ae13b..569b76925 100644
--- a/doc/LPegLexer.html
+++ b/doc/LPegLexer.html
@@ -1606,14 +1606,14 @@ operator 30
-
+
- lexer.fold_line_comments (boolean)
+ lexer.fold_line_groups (boolean)
- Whether or not to fold multiple, consecutive line comments and only show
- the top-level comment.
+
Whether or not to fold multiple, consecutive line groups (such as line
+ comments or import statements) and only show the top line.
This option is disabled by default.
- This is an alias for lexer.property['fold.line.comments'] = '1|0'.
+ This is an alias for lexer.property['fold.line.groups'] = '1|0'.
@@ -1928,27 +1928,26 @@ operator 30
-
+
- lexer.fold_line_comments (prefix)
+ lexer.fold_consecutive_lines (prefix)
- Returns a fold function (to be passed to lexer.add_fold_point()) that folds
- consecutive line comments that start with string prefix.
+ Returns for lexer.add_fold_point() the parameters needed to fold
+ consecutive lines that start with string prefix.
Parameters:
- prefix: The prefix string defining a line comment.
+ prefix: The prefix string (e.g. a line comment).
Usage:
- lex:add_fold_point(lexer.COMMENT, '--',
- lexer.fold_line_comments('--'))
- lex:add_fold_point(lexer.COMMENT, '//',
- lexer.fold_line_comments('//'))
+ lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('--'))
+ lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
+ lex:add_fold_point(lexer.KEYWORD, lexer.fold_consecutive_lines('import'))
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 026a37c3d..8d090f5fa 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -603,6 +603,10 @@
Feature #1361.
+ The curses platform's scintilla_get_clipboard() now returns a
+ copy of clipboard text directly.
+
+
Fix translucent rectangle drawing on Qt. When drawing a translucent selection, there were edge
artifacts as the calls used were drawing outlines over fill areas. Make bottom and right borders on
INDIC_ROUNDBOX be same intensity as top and left.
@@ -650,6 +654,10 @@
The Lua LPeg lexer for C now highlights C99 bool, true, and false.
+ Fixed crashes in Lua LPeg lexer when "lexer.lua" cannot be found, and when
+ attempting to set styles for non-existant tokens.
+
+
Fixed bug with GTK on recent Linux distributions where underscores were invisible.
Bug #2173.
diff --git a/lexlua/actionscript.lua b/lexlua/actionscript.lua
index 3202a9a01..937541053 100644
--- a/lexlua/actionscript.lua
+++ b/lexlua/actionscript.lua
@@ -52,7 +52,7 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/*%&|^~.,;?()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
lex:add_fold_point(lexer.STRING, '')
return lex
diff --git a/lexlua/ansi_c.lua b/lexlua/ansi_c.lua
index 7c281916c..1c6f1c187 100644
--- a/lexlua/ansi_c.lua
+++ b/lexlua/ansi_c.lua
@@ -81,6 +81,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, '#ifdef', '#endif')
lex:add_fold_point(lexer.PREPROCESSOR, '#ifndef', '#endif')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/antlr.lua b/lexlua/antlr.lua
index b9d10c2cc..6f78d88b8 100644
--- a/lexlua/antlr.lua
+++ b/lexlua/antlr.lua
@@ -51,6 +51,6 @@ lex:add_fold_point(lexer.OPERATOR, ':', ';')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/apdl.lua b/lexlua/apdl.lua
index 148913c6c..06f79ba28 100644
--- a/lexlua/apdl.lua
+++ b/lexlua/apdl.lua
@@ -67,6 +67,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/$=,;()')))
lex:add_fold_point(lexer.KEYWORD, '*if', '*endif')
lex:add_fold_point(lexer.KEYWORD, '*do', '*enddo')
lex:add_fold_point(lexer.KEYWORD, '*dowhile', '*enddo')
-lex:add_fold_point(lexer.COMMENT, '!', lexer.fold_line_comments('!'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('!'))
return lex
diff --git a/lexlua/asm.lua b/lexlua/asm.lua
index 7aca5a392..1fda26e76 100644
--- a/lexlua/asm.lua
+++ b/lexlua/asm.lua
@@ -357,6 +357,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, '%macro', '%endmacro')
lex:add_fold_point(lexer.PREPROCESSOR, '%rep', '%endrep')
lex:add_fold_point(lexer.PREPROCESSOR, '%while', '%endwhile')
lex:add_fold_point(lexer.KEYWORD, 'struc', 'endstruc')
-lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines(';'))
return lex
diff --git a/lexlua/awk.lua b/lexlua/awk.lua
index a1b4779eb..4bba2309b 100644
--- a/lexlua/awk.lua
+++ b/lexlua/awk.lua
@@ -292,6 +292,6 @@ lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/bash.lua b/lexlua/bash.lua
index ddf87e63c..3b450eaeb 100644
--- a/lexlua/bash.lua
+++ b/lexlua/bash.lua
@@ -54,6 +54,6 @@ lex:add_fold_point(lexer.KEYWORD, 'if', 'fi')
lex:add_fold_point(lexer.KEYWORD, 'case', 'esac')
lex:add_fold_point(lexer.KEYWORD, 'do', 'done')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/cmake.lua b/lexlua/cmake.lua
index ea6d472bb..c5e2dd181 100644
--- a/lexlua/cmake.lua
+++ b/lexlua/cmake.lua
@@ -135,6 +135,6 @@ lex:add_fold_point(lexer.KEYWORD, 'WHILE', 'ENDWHILE')
lex:add_fold_point(lexer.FUNCTION, 'MACRO', 'ENDMACRO')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/context.lua b/lexlua/context.lua
index 7ff82f541..e5d567f09 100644
--- a/lexlua/context.lua
+++ b/lexlua/context.lua
@@ -47,7 +47,7 @@ lex:add_rule('operator', operator)
lex:add_fold_point('environment', '\\start', '\\stop')
lex:add_fold_point('environment', '\\begin', '\\end')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('%'))
-- Embedded Lua.
local luatex = lexer.load('lua')
diff --git a/lexlua/cpp.lua b/lexlua/cpp.lua
index 0f04061fe..42d5e624a 100644
--- a/lexlua/cpp.lua
+++ b/lexlua/cpp.lua
@@ -71,6 +71,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif')
lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/crystal.lua b/lexlua/crystal.lua
index e40e6f888..5280c628e 100644
--- a/lexlua/crystal.lua
+++ b/lexlua/crystal.lua
@@ -120,6 +120,6 @@ lex:add_fold_point(lexer.KEYWORD, 'until', disambiguate)
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.OPERATOR, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/csharp.lua b/lexlua/csharp.lua
index eff79c533..d81302ea0 100644
--- a/lexlua/csharp.lua
+++ b/lexlua/csharp.lua
@@ -60,6 +60,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif')
lex:add_fold_point(lexer.PREPROCESSOR, 'region', 'endregion')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/dart.lua b/lexlua/dart.lua
index 6ca08208e..33247ca7e 100644
--- a/lexlua/dart.lua
+++ b/lexlua/dart.lua
@@ -51,6 +51,6 @@ lex:add_style('annotation', lexer.styles.preprocessor)
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/dot.lua b/lexlua/dot.lua
index 6b298b47a..8ce76d72d 100644
--- a/lexlua/dot.lua
+++ b/lexlua/dot.lua
@@ -50,6 +50,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('->()[]{};')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/eiffel.lua b/lexlua/eiffel.lua
index 7dc95fecd..b4df68065 100644
--- a/lexlua/eiffel.lua
+++ b/lexlua/eiffel.lua
@@ -56,6 +56,6 @@ lex:add_fold_point(lexer.KEYWORD, 'once', 'end')
lex:add_fold_point(lexer.KEYWORD, 'class', function(text, pos, line, s)
return line:find('deferred%s+class') and 0 or 1
end)
-lex:add_fold_point(lexer.COMMENT, '--', lexer.fold_line_comments('--'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('--'))
return lex
diff --git a/lexlua/erlang.lua b/lexlua/erlang.lua
index df5448866..e1ce59482 100644
--- a/lexlua/erlang.lua
+++ b/lexlua/erlang.lua
@@ -85,6 +85,6 @@ lex:add_fold_point(lexer.KEYWORD, 'receive', 'end')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('%'))
return lex
diff --git a/lexlua/gap.lua b/lexlua/gap.lua
index 779a93e73..f8e0969d4 100644
--- a/lexlua/gap.lua
+++ b/lexlua/gap.lua
@@ -38,6 +38,6 @@ lex:add_fold_point(lexer.KEYWORD, 'function', 'end')
lex:add_fold_point(lexer.KEYWORD, 'do', 'od')
lex:add_fold_point(lexer.KEYWORD, 'if', 'fi')
lex:add_fold_point(lexer.KEYWORD, 'repeat', 'until')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/go.lua b/lexlua/go.lua
index 95b8caa16..2b01487c5 100644
--- a/lexlua/go.lua
+++ b/lexlua/go.lua
@@ -56,6 +56,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%&|^<>=!:;.,()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/groovy.lua b/lexlua/groovy.lua
index ed0caeb54..6f9bfd3c6 100644
--- a/lexlua/groovy.lua
+++ b/lexlua/groovy.lua
@@ -63,6 +63,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('=~|!<>+-/*?&.,:;()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/gtkrc.lua b/lexlua/gtkrc.lua
index 59baa37fd..acf3b37c5 100644
--- a/lexlua/gtkrc.lua
+++ b/lexlua/gtkrc.lua
@@ -54,6 +54,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S(':=,*()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/icon.lua b/lexlua/icon.lua
index 46abf8833..913e7b6e2 100644
--- a/lexlua/icon.lua
+++ b/lexlua/icon.lua
@@ -56,6 +56,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>~!=^&|?~@:;,.()[]{}')))
lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif')
lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif')
lex:add_fold_point(lexer.KEYWORD, 'procedure', 'end')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/io_lang.lua b/lexlua/io_lang.lua
index c98b1acd3..6660d0640 100644
--- a/lexlua/io_lang.lua
+++ b/lexlua/io_lang.lua
@@ -46,6 +46,6 @@ lex:add_rule('operator', token(lexer.OPERATOR,
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/java.lua b/lexlua/java.lua
index 85466fe35..182c8ca9a 100644
--- a/lexlua/java.lua
+++ b/lexlua/java.lua
@@ -61,6 +61,7 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
+lex:add_fold_point(lexer.KEYWORD, lexer.fold_consecutive_lines('import'))
return lex
diff --git a/lexlua/javascript.lua b/lexlua/javascript.lua
index 92ad67ede..592ef5173 100644
--- a/lexlua/javascript.lua
+++ b/lexlua/javascript.lua
@@ -47,6 +47,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%^!=&|?:;,.()[]{}<>')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/json.lua b/lexlua/json.lua
index eaddb0d56..85c978e47 100644
--- a/lexlua/json.lua
+++ b/lexlua/json.lua
@@ -35,6 +35,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('[]{}:,')))
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/latex.lua b/lexlua/latex.lua
index b82af0fac..e28b30480 100644
--- a/lexlua/latex.lua
+++ b/lexlua/latex.lua
@@ -48,7 +48,7 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('{}[]')))
-- Fold points.
lex:add_fold_point(lexer.COMMENT, '\\begin', '\\end')
-lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('%'))
lex:add_fold_point('environment', '\\begin', '\\end')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
diff --git a/lexlua/less.lua b/lexlua/less.lua
index ee8fc8896..a860e82f0 100644
--- a/lexlua/less.lua
+++ b/lexlua/less.lua
@@ -16,6 +16,6 @@ lex:add_rule('variable', token(lexer.VARIABLE, '@' *
(lexer.alnum + S('_-{}'))^1))
-- Fold points.
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/lexer.lua b/lexlua/lexer.lua
index 828782ad9..299776297 100644
--- a/lexlua/lexer.lua
+++ b/lexlua/lexer.lua
@@ -866,11 +866,11 @@ local M = {}
-- a folder.
-- Some lexers automatically enable this option. It is disabled by default.
-- This is an alias for `lexer.property['fold.by.indentation'] = '1|0'`.
--- @field fold_line_comments (boolean)
--- Whether or not to fold multiple, consecutive line comments and only show
--- the top-level comment.
+-- @field fold_line_groups (boolean)
+-- Whether or not to fold multiple, consecutive line groups (such as line
+-- comments and import statements) and only show the top line.
-- This option is disabled by default.
--- This is an alias for `lexer.property['fold.line.comments'] = '1|0'`.
+-- This is an alias for `lexer.property['fold.line.groups'] = '1|0'`.
module('lexer')]=]
if not require then
@@ -1133,7 +1133,7 @@ end
-- point (1), an ending fold point (-1), or not a fold point at all (0).
-- @usage lex:add_fold_point(lexer.OPERATOR, '{', '}')
-- @usage lex:add_fold_point(lexer.KEYWORD, 'if', 'end')
--- @usage lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+-- @usage lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
-- @usage lex:add_fold_point('custom', function(text, pos, line, s, symbol)
-- ... end)
-- @name add_fold_point
@@ -1921,6 +1921,28 @@ local function next_line_is_comment(prefix, text, pos, line, s)
end
---
+-- Returns for `lexer.add_fold_point()` the parameters needed to fold
+-- consecutive lines that start with string *prefix*.
+-- @param prefix The prefix string (e.g. a line comment).
+-- @usage lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('--'))
+-- @usage lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
+-- @usage lex:add_fold_point(
+-- lexer.KEYWORD, lexer.fold_consecutive_lines('import'))
+-- @name fold_consecutive_lines
+function M.fold_consecutive_lines(prefix)
+ local property_int = M.property_int
+ return prefix, function(text, pos, line, s)
+ if property_int['fold.line.groups'] == 0 then return 0 end
+ if s > 1 and line:match('^%s*()') < s then return 0 end
+ local prev_line_comment = prev_line_is_comment(prefix, text, pos, line, s)
+ local next_line_comment = next_line_is_comment(prefix, text, pos, line, s)
+ if not prev_line_comment and next_line_comment then return 1 end
+ if prev_line_comment and not next_line_comment then return -1 end
+ return 0
+ end
+end
+
+-- Deprecated legacy function. Use `lexer.fold_consecutive_lines()` instead.
-- Returns a fold function (to be passed to `lexer.add_fold_point()`) that folds
-- consecutive line comments that start with string *prefix*.
-- @param prefix The prefix string defining a line comment.
@@ -1930,16 +1952,10 @@ end
-- lexer.fold_line_comments('//'))
-- @name fold_line_comments
function M.fold_line_comments(prefix)
- local property_int = M.property_int
- return function(text, pos, line, s)
- if property_int['fold.line.comments'] == 0 then return 0 end
- if s > 1 and line:match('^%s*()') < s then return 0 end
- local prev_line_comment = prev_line_is_comment(prefix, text, pos, line, s)
- local next_line_comment = next_line_is_comment(prefix, text, pos, line, s)
- if not prev_line_comment and next_line_comment then return 1 end
- if prev_line_comment and not next_line_comment then return -1 end
- return 0
- end
+ print(
+ "lexer.fold_line_comments() is deprecated, " ..
+ "use lexer.fold_consecutive_lines()")
+ return select(2, M.fold_consecutive_lines(prefix))
end
M.property_expanded = setmetatable({}, {
diff --git a/lexlua/lisp.lua b/lexlua/lisp.lua
index 7c2cda738..bc127a925 100644
--- a/lexlua/lisp.lua
+++ b/lexlua/lisp.lua
@@ -59,6 +59,6 @@ lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '#|', '|#')
-lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines(';'))
return lex
diff --git a/lexlua/lua.lua b/lexlua/lua.lua
index 6a42a032c..b046c710a 100644
--- a/lexlua/lua.lua
+++ b/lexlua/lua.lua
@@ -153,7 +153,7 @@ lex:add_fold_point(lexer.KEYWORD, 'function', 'end')
lex:add_fold_point(lexer.KEYWORD, 'repeat', 'until')
lex:add_fold_point(lexer.COMMENT, '[', fold_longcomment)
lex:add_fold_point(lexer.COMMENT, ']', fold_longcomment)
-lex:add_fold_point(lexer.COMMENT, '--', lexer.fold_line_comments('--'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('--'))
lex:add_fold_point('longstring', '[', ']')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
diff --git a/lexlua/matlab.lua b/lexlua/matlab.lua
index 27a51b0b2..fb3f9b161 100644
--- a/lexlua/matlab.lua
+++ b/lexlua/matlab.lua
@@ -79,7 +79,7 @@ lex:add_fold_point(lexer.KEYWORD, 'switch', 'end')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.COMMENT, '%{', '%}')
-lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%'))
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('%'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/nemerle.lua b/lexlua/nemerle.lua
index 03d3db3a2..ec1fa56a7 100644
--- a/lexlua/nemerle.lua
+++ b/lexlua/nemerle.lua
@@ -61,6 +61,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif')
lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/objective_c.lua b/lexlua/objective_c.lua
index 026d83f0a..3b1b5f436 100644
--- a/lexlua/objective_c.lua
+++ b/lexlua/objective_c.lua
@@ -65,6 +65,6 @@ lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif')
lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/perl.lua b/lexlua/perl.lua
index 8021f3ea4..9054c3e64 100644
--- a/lexlua/perl.lua
+++ b/lexlua/perl.lua
@@ -134,6 +134,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('-<>+*!~\\=/%&|^.?:;()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/php.lua b/lexlua/php.lua
index 07886f950..79a6b2fd8 100644
--- a/lexlua/php.lua
+++ b/lexlua/php.lua
@@ -67,8 +67,8 @@ lex:add_style('php_tag', lexer.styles.embedded)
-- Fold points.
lex:add_fold_point('php_tag', '', '?>')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
diff --git a/lexlua/pike.lua b/lexlua/pike.lua
index f0667d6ed..62c4d58e4 100644
--- a/lexlua/pike.lua
+++ b/lexlua/pike.lua
@@ -51,6 +51,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('<>=!+-/*%&|^~@`.,:;()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/pkgbuild.lua b/lexlua/pkgbuild.lua
index 88c25d76b..1c2e7b4f8 100644
--- a/lexlua/pkgbuild.lua
+++ b/lexlua/pkgbuild.lua
@@ -74,6 +74,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/*^~.,:;?()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/rc.lua b/lexlua/rc.lua
index 749911a6e..d7e7adacc 100644
--- a/lexlua/rc.lua
+++ b/lexlua/rc.lua
@@ -48,6 +48,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('@`=!<>*&^|;?()[]{}') +
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/rebol.lua b/lexlua/rebol.lua
index dcf71dfbb..74fe01bed 100644
--- a/lexlua/rebol.lua
+++ b/lexlua/rebol.lua
@@ -92,7 +92,7 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('=<>+/*:()[]')))
-- Fold points.
lex:add_fold_point(lexer.COMMENT, '{', '}')
-lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines(';'))
lex:add_fold_point(lexer.OPERATOR, '[', ']')
return lex
diff --git a/lexlua/rexx.lua b/lexlua/rexx.lua
index 97036b8aa..fa1612704 100644
--- a/lexlua/rexx.lua
+++ b/lexlua/rexx.lua
@@ -71,7 +71,7 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/\\*%&|^~.,:;(){}')))
lex:add_fold_point(lexer.KEYWORD, 'do', 'end')
lex:add_fold_point(lexer.KEYWORD, 'select', 'return')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '--', lexer.fold_line_comments('--'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('--'))
--lex:add_fold_point(lexer.OPERATOR, ':', ?)
return lex
diff --git a/lexlua/ruby.lua b/lexlua/ruby.lua
index cdfed8ae3..ca9b9b818 100644
--- a/lexlua/ruby.lua
+++ b/lexlua/ruby.lua
@@ -126,6 +126,6 @@ lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '[', ']')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '=begin', '=end')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/rust.lua b/lexlua/rust.lua
index af1184e12..07c8f52f9 100644
--- a/lexlua/rust.lua
+++ b/lexlua/rust.lua
@@ -87,7 +87,7 @@ lex:add_rule('operator', token(lexer.OPERATOR,
-- Fold points.
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
diff --git a/lexlua/sass.lua b/lexlua/sass.lua
index e4faf1cc3..1a6c0e6bc 100644
--- a/lexlua/sass.lua
+++ b/lexlua/sass.lua
@@ -19,6 +19,6 @@ lex:add_rule('mixin', token('mixin', P('@') * lexer.word))
lex:add_style('mixin', lexer.styles['function'])
-- Fold points.
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/scala.lua b/lexlua/scala.lua
index e389f80ff..db4c23451 100644
--- a/lexlua/scala.lua
+++ b/lexlua/scala.lua
@@ -55,6 +55,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/scheme.lua b/lexlua/scheme.lua
index 3c60b017d..cb7eefd3d 100644
--- a/lexlua/scheme.lua
+++ b/lexlua/scheme.lua
@@ -75,6 +75,6 @@ lex:add_style('entity', lexer.styles.variable)
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.COMMENT, '#|', '|#')
-lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines(';'))
return lex
diff --git a/lexlua/tcl.lua b/lexlua/tcl.lua
index 4f8a7eb64..675397a7c 100644
--- a/lexlua/tcl.lua
+++ b/lexlua/tcl.lua
@@ -43,6 +43,6 @@ lex:add_rule('backslash', token(lexer.TYPE, '\\' * (oct + hex + unicode + 1)))
-- Fold points.
lex:add_fold_point(lexer.KEYWORD, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/template.txt b/lexlua/template.txt
index d12f41c66..48ac20319 100644
--- a/lexlua/template.txt
+++ b/lexlua/template.txt
@@ -34,6 +34,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%^=<>,.{}[]()')))
-- Fold points.
lex:add_fold_point(lexer.KEYWORD, 'start', 'end')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
-lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#'))
return lex
diff --git a/lexlua/tex.lua b/lexlua/tex.lua
index 5dfb9ea0e..cf5f94d0f 100644
--- a/lexlua/tex.lua
+++ b/lexlua/tex.lua
@@ -27,7 +27,7 @@ lex:add_rule('command', token(lexer.KEYWORD, '\\' * (lexer.alpha^1 +
lex:add_rule('operator', token(lexer.OPERATOR, S('${}[]')))
-- Fold points.
-lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('%'))
lex:add_fold_point('environment', '\\begin', '\\end')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
diff --git a/lexlua/vala.lua b/lexlua/vala.lua
index ca2fd579e..18ab50dbc 100644
--- a/lexlua/vala.lua
+++ b/lexlua/vala.lua
@@ -54,6 +54,6 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/verilog.lua b/lexlua/verilog.lua
index c9fba0bd8..600af7d1e 100644
--- a/lexlua/verilog.lua
+++ b/lexlua/verilog.lua
@@ -80,6 +80,6 @@ lex:add_fold_point(lexer.KEYWORD, 'begin', 'end')
lex:add_fold_point(lexer.OPERATOR, '(', ')')
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
return lex
diff --git a/lexlua/xtend.lua b/lexlua/xtend.lua
index f9a910f7d..c86bf7820 100644
--- a/lexlua/xtend.lua
+++ b/lexlua/xtend.lua
@@ -84,7 +84,7 @@ lex:add_rule('error', token(lexer.ERROR, lexer.any))
-- Fold points.
lex:add_fold_point(lexer.OPERATOR, '{', '}')
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
-lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//'))
-lex:add_fold_point(lexer.KEYWORD, 'import', lexer.fold_line_comments('import'))
+lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('//'))
+lex:add_fold_point(lexer.KEYWORD, lexer.fold_consecutive_lines('import'))
return lex
--
cgit v1.2.3