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.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.lua')
| -rw-r--r-- | lua/vis.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/vis.lua b/lua/vis.lua index 870fc52..479d1ee 100644 --- a/lua/vis.lua +++ b/lua/vis.lua @@ -113,6 +113,8 @@ vis.module_exist = function(vis, name) return false end +vis.lexers = {} + if not vis:module_exist('lpeg') then vis:info('WARNING: could not find lpeg module') elseif not vis:module_exist('lexer') then @@ -235,7 +237,6 @@ vis.events = events vis.types.window.set_syntax = function(win, syntax) local lexers = vis.lexers - if not lexers then return false end win:style_define(win.STYLE_DEFAULT, lexers.STYLE_DEFAULT or '') win:style_define(win.STYLE_CURSOR, lexers.STYLE_CURSOR or '') @@ -256,6 +257,7 @@ vis.types.window.set_syntax = function(win, syntax) return true end + if not lexers.load then return false end local lexer = lexers.load(syntax) if not lexer then return false end |
