aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/lexer.lua
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-01-19 20:54:01 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-19 21:08:30 +0100
commit242f22f2ef7aeb14c36e54d7d44d3fd4e51a5d06 (patch)
tree6bf146e1635cf0f427b4f1c0ad888fb4993bc726 /lua/lexers/lexer.lua
parent8e7a73bb1f697f61efce016e6d9a4b8840bd0878 (diff)
downloadvis-242f22f2ef7aeb14c36e54d7d44d3fd4e51a5d06.tar.gz
vis-242f22f2ef7aeb14c36e54d7d44d3fd4e51a5d06.tar.xz
lexer: sync with scintillua changeset 582 rev d70a5ee43d38
Diffstat (limited to 'lua/lexers/lexer.lua')
-rw-r--r--lua/lexers/lexer.lua32
1 files changed, 22 insertions, 10 deletions
diff --git a/lua/lexers/lexer.lua b/lua/lexers/lexer.lua
index b896344..d159f70 100644
--- a/lua/lexers/lexer.lua
+++ b/lua/lexers/lexer.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
+-- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
local M = {}
@@ -566,13 +566,14 @@ local M = {}
-- `_foldsymbols` table must have a `_patterns` field that contains a list of
-- [Lua patterns][] that match fold points. If the lexer encounters text that
-- matches one of those patterns, the lexer looks up the matched text in its
--- token's table to determine whether or not the text is a fold point. In the
--- example above, the first Lua pattern matches any '{' or '}' characters. When
--- the lexer comes across one of those characters, it checks if the match is an
--- `lexer.OPERATOR` token. If so, the lexer identifies the match as a fold
--- point. The same idea applies for the other patterns. (The '%' is in the other
--- patterns because '\*' is a special character in Lua patterns that needs
--- escaping.) How do you specify fold keywords? Here is an example for Lua:
+-- token's table in order to determine whether or not the text is a fold point.
+-- In the example above, the first Lua pattern matches any '{' or '}'
+-- characters. When the lexer comes across one of those characters, it checks if
+-- the match is an `lexer.OPERATOR` token. If so, the lexer identifies the match
+-- as a fold point. The same idea applies for the other patterns. (The '%' is in
+-- the other patterns because '\*' is a special character in Lua patterns that
+-- needs escaping.) How do you specify fold keywords? Here is an example for
+-- Lua:
--
-- M._foldsymbols = {
-- [l.KEYWORD] = {
@@ -586,6 +587,10 @@ local M = {}
-- `lexer.KEYWORD` token and in the associated list of fold points, the lexer
-- identifies the word as a fold point.
--
+-- If your lexer has case-insensitive keywords as fold points, simply add a
+-- `_case_insensitive = true` option to the `_foldsymbols` table and specify
+-- keywords in lower case.
+--
-- If your lexer needs to do some additional processing to determine if a match
-- is a fold point, assign a function that returns an integer. Returning `1` or
-- `-1` indicates the match is a fold point. Returning `0` indicates it is not.
@@ -785,6 +790,8 @@ local M = {}
-- @field STYLE_CALLTIP (string)
-- The style used by call tips if [`buffer.call_tip_use_style`]() is set.
-- Only the font name, size, and color attributes are used.
+-- @field STYLE_FOLDDISPLAYTEXT (string)
+-- The style used for fold display text.
-- @field any (pattern)
-- A pattern that matches any single character.
-- @field ascii (pattern)
@@ -1002,7 +1009,7 @@ end
-- Predefined styles.
local predefined = {
'default', 'linenumber', 'bracelight', 'bracebad', 'controlchar',
- 'indentguide', 'calltip'
+ 'indentguide', 'calltip', 'folddisplaytext'
}
for i = 1, #predefined do
local name, upper_name = predefined[i], string_upper(predefined[i])
@@ -1182,12 +1189,14 @@ function M.fold(lexer, text, start_pos, start_line, start_level)
local fold_zero_sum_lines = M.property_int['fold.on.zero.sum.lines'] > 0
local fold_symbols = lexer._foldsymbols
local fold_symbols_patterns = fold_symbols._patterns
+ local fold_symbols_case_insensitive = fold_symbols._case_insensitive
local style_at, fold_level = M.style_at, M.fold_level
local line_num, prev_level = start_line, start_level
local current_level = prev_level
for i = 1, #lines do
local pos, line = lines[i][1], lines[i][2]
if line ~= '' then
+ if fold_symbols_case_insensitive then line = line:lower() end
local level_decreased = false
for j = 1, #fold_symbols_patterns do
for s, match in line:gmatch(fold_symbols_patterns[j]) do
@@ -1605,11 +1614,14 @@ local function line_from_position(pos) end
-- point and a value of `-1` indicates an ending fold point. Values can also
-- be functions that return `1`, `-1`, or `0` (indicating no fold point) for
-- keys which need additional processing.
--- There is also a required `_pattern` key whose value is a table containing
+-- There is also a required `_patterns` key whose value is a table containing
-- Lua pattern strings that match all fold points (the string keys contained
-- in token name table values). When the lexer encounters text that matches
-- one of those patterns, the matched text is looked up in its token's table
-- to determine whether or not it is a fold point.
+-- There is also an optional `_case_insensitive` option that indicates whether
+-- or not fold point keys are case-insensitive. If `true`, fold point keys
+-- should be in lower case.
-- @field _fold If this function exists in the lexer, it is called for folding
-- the document instead of using `_foldsymbols` or indentation.
-- @field _lexer The parent lexer object whose rules should be used. This field