diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2018-01-22 16:13:09 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2018-01-22 21:50:05 +0100 |
| commit | 5b8042ab1aa986d27e8974dbffe96bda6af61faf (patch) | |
| tree | bf391f6c5bbb89a05ba35b73f64b7abb914d3156 /lua/vis-std.lua | |
| parent | a94b52f7970ea5e6aa68fc5f5aa6c7de7884c7c7 (diff) | |
| download | vis-5b8042ab1aa986d27e8974dbffe96bda6af61faf.tar.gz vis-5b8042ab1aa986d27e8974dbffe96bda6af61faf.tar.xz | |
lua: fix theme loading when lexer module is not available
The color settings are currently stored in the `vis.lexers` table,
make sure it is not nil even when loading the lexer module (or one
of its dependencies e.g. lpeg) failed.
Diffstat (limited to 'lua/vis-std.lua')
| -rw-r--r-- | lua/vis-std.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lua/vis-std.lua b/lua/vis-std.lua index 5f41b4d..f0607f2 100644 --- a/lua/vis-std.lua +++ b/lua/vis-std.lua @@ -14,7 +14,7 @@ vis:option_register("theme", "string", function(name) require(theme) end - if vis.lexers then vis.lexers.lexers = {} end + vis.lexers.lexers = {} for win in vis:windows() do win:set_syntax(win.syntax) @@ -38,9 +38,9 @@ vis:option_register("horizon", "number", function(horizon) end, "Number of bytes to consider for syntax highlighting") vis.events.subscribe(vis.events.WIN_HIGHLIGHT, function(win) - if win.syntax == nil or vis.lexers == nil then return end + if not win.syntax or not vis.lexers.load then return end local lexer = vis.lexers.load(win.syntax, nil, true) - if lexer == nil then return end + if not lexer then return end -- TODO: improve heuristic for initial style local viewport = win.viewport |
