From 5b8042ab1aa986d27e8974dbffe96bda6af61faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 22 Jan 2018 16:13:09 +0100 Subject: 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. --- lua/vis-std.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lua/vis-std.lua') 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 -- cgit v1.2.3