diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-22 11:54:40 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-22 12:03:53 +0200 |
| commit | 4339f4f6ca8f5576c0f96cb2a9e7dc07ce34e3f7 (patch) | |
| tree | f2ec423b9f0a04a767f50f3dade8348d9e4eb7e5 /vis.lua | |
| parent | 08e7ef90ca00315c4f994d20e64f67611c3fc4b5 (diff) | |
| download | vis-4339f4f6ca8f5576c0f96cb2a9e7dc07ce34e3f7.tar.gz vis-4339f4f6ca8f5576c0f96cb2a9e7dc07ce34e3f7.tar.xz | |
vis: load default styles even for unknown file types
Diffstat (limited to 'vis.lua')
| -rw-r--r-- | vis.lua | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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 |
