vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 780f47c2d1be5a21692dd3ee944a083d37bae6d8
parent 4b89fa7a7b9644e40ef923a55be04d0eaf40f007
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun, 22 May 2016 11:54:40 +0200

vis: load default styles even for unknown file types

Diffstat:
Mvis.lua | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/vis.lua b/vis.lua @@ -223,15 +223,8 @@ vis.events.theme_change = function(name) end vis.events.win_syntax = function(win, name) - if name == nil then - return true - end local lexers = vis.lexers - if lexers == nil then - return false - end - local lexer = lexers.load(name) - if not lexer then + if not lexers.load then return false end @@ -243,10 +236,20 @@ vis.events.win_syntax = function(win, name) win:style_define(win.STYLE_LINENUMBER, lexers.STYLE_LINENUMBER) win:style_define(win.STYLE_COLOR_COLUMN, lexers.STYLE_COLOR_COLUMN) + if name == nil then + return true + end + + local lexer = lexers.load(name) + if not lexer then + return false + end + for token_name, id in pairs(lexer._TOKENSTYLES) do local style = lexers['STYLE_'..string.upper(token_name)] or lexer._EXTRASTYLES[token_name] win:style_define(id, style) end + return true end