Diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/extensions/fake-lexers/lexer.lua | 17 |
1 file changed, 8 insertions, 9 deletions
diff --git a/tests/extensions/fake-lexers/lexer.lua b/tests/extensions/fake-lexers/lexer.lua index ea7768e..bb869de 100644 --- a/tests/extensions/fake-lexers/lexer.lua +++ b/tests/extensions/fake-lexers/lexer.lua @@ -1,10 +1,10 @@ -- A miniature stand-in for the Scintillua lexer module, just enough for the -- syntax-highlight checks to drive every path through the filter without the --- real collection installed. load() hands out one of the toy lexers below by --- name and detect() recognises a single filename suffix or a shebang naming --- fake, so a check can tell the detection path apart from the extension path --- by which lexer ends up running. Anything the filter treats as optional, a lexer that will not --- load or one that raises while lexing, has a name here too. +-- real collection installed. detect() answers for the suffixes it knows, +-- matched by case as Scintillua's own does, or fake for a shebang naming it, +-- and load() hands out the toy lexer of that name. Besides fake there is one +-- that stops short and one that raises, and python, which detect() knows but +-- load() cannot find, as a collection missing a lexer would answer. local M = {} @@ -68,14 +68,13 @@ function M.load(name) return lexer end +local suffixes = { fake = "fake", short = "short", badlex = "badlex", py = "python" } + function M.detect(filename, line) - if filename:match("%.viadetect$") then - return "fake" - end if line ~= nil and line:match("^#!.*fake") then return "fake" end - return nil + return suffixes[filename:match("%.([^.]+)$") or ""] end return M |
