diff options
| -rw-r--r-- | lua/plugins/number-inc-dec.lua | 2 | ||||
| -rw-r--r-- | lua/plugins/textobject-lexer.lua | 2 | ||||
| -rw-r--r-- | lua/vis-std.lua | 6 | ||||
| -rw-r--r-- | lua/vis.lua | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/lua/plugins/number-inc-dec.lua b/lua/plugins/number-inc-dec.lua index 26a8825..ca794ca 100644 --- a/lua/plugins/number-inc-dec.lua +++ b/lua/plugins/number-inc-dec.lua @@ -1,7 +1,7 @@ -- increment/decrement number in dec/hex/oct format local lexer = vis.lexers local lpeg = vis.lpeg -if not lexer or not lpeg then return end +if not lexer.load or not lpeg then return end local Cp = lpeg.Cp() local dec_num = lpeg.S('+-')^-1 * lexer.dec_num diff --git a/lua/plugins/textobject-lexer.lua b/lua/plugins/textobject-lexer.lua index fc4876b..2f9d757 100644 --- a/lua/plugins/textobject-lexer.lua +++ b/lua/plugins/textobject-lexer.lua @@ -4,7 +4,7 @@ local MAX_CONTEXT = 32768 vis:textobject_new("ii", function(win, pos) - if win.syntax == nil or not vis.lexers then + if not win.syntax or not vis.lexers.load then return nil end 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 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 |
