aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlua
diff options
context:
space:
mode:
authormitchell <unknown>2020-08-03 18:48:30 -0400
committermitchell <unknown>2020-08-03 18:48:30 -0400
commit7e647657b0f95a4756b8aa714b0b3e4295272b81 (patch)
treeaba57ef6f834d046fb0a0f19102418bf9f40652a /lexlua
parent79621db631f816c375b91edd2491bfe4b0aee5fa (diff)
downloadscintilla-mirror-7e647657b0f95a4756b8aa714b0b3e4295272b81.tar.gz
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.
Diffstat (limited to 'lexlua')
-rw-r--r--lexlua/actionscript.lua2
-rw-r--r--lexlua/ansi_c.lua2
-rw-r--r--lexlua/antlr.lua2
-rw-r--r--lexlua/apdl.lua2
-rw-r--r--lexlua/asm.lua2
-rw-r--r--lexlua/awk.lua2
-rw-r--r--lexlua/bash.lua2
-rw-r--r--lexlua/cmake.lua2
-rw-r--r--lexlua/context.lua2
-rw-r--r--lexlua/cpp.lua2
-rw-r--r--lexlua/crystal.lua2
-rw-r--r--lexlua/csharp.lua2
-rw-r--r--lexlua/dart.lua2
-rw-r--r--lexlua/dot.lua2
-rw-r--r--lexlua/eiffel.lua2
-rw-r--r--lexlua/erlang.lua2
-rw-r--r--lexlua/gap.lua2
-rw-r--r--lexlua/go.lua2
-rw-r--r--lexlua/groovy.lua2
-rw-r--r--lexlua/gtkrc.lua2
-rw-r--r--lexlua/icon.lua2
-rw-r--r--lexlua/io_lang.lua2
-rw-r--r--lexlua/java.lua3
-rw-r--r--lexlua/javascript.lua2
-rw-r--r--lexlua/json.lua2
-rw-r--r--lexlua/latex.lua2
-rw-r--r--lexlua/less.lua2
-rw-r--r--lexlua/lexer.lua46
-rw-r--r--lexlua/lisp.lua2
-rw-r--r--lexlua/lua.lua2
-rw-r--r--lexlua/matlab.lua4
-rw-r--r--lexlua/nemerle.lua2
-rw-r--r--lexlua/objective_c.lua2
-rw-r--r--lexlua/perl.lua2
-rw-r--r--lexlua/php.lua4
-rw-r--r--lexlua/pike.lua2
-rw-r--r--lexlua/pkgbuild.lua2
-rw-r--r--lexlua/rc.lua2
-rw-r--r--lexlua/rebol.lua2
-rw-r--r--lexlua/rexx.lua2
-rw-r--r--lexlua/ruby.lua2
-rw-r--r--lexlua/rust.lua2
-rw-r--r--lexlua/sass.lua2
-rw-r--r--lexlua/scala.lua2
-rw-r--r--lexlua/scheme.lua2
-rw-r--r--lexlua/tcl.lua2
-rw-r--r--lexlua/template.txt2
-rw-r--r--lexlua/tex.lua2
-rw-r--r--lexlua/vala.lua2
-rw-r--r--lexlua/verilog.lua2
-rw-r--r--lexlua/xtend.lua4
51 files changed, 85 insertions, 68 deletions
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, '<![CDATA[', ']]>')
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