fork of github.com/rxi/lite that removes windows support and improves useability
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
lite/data/core/syntax.lua

30 lines
537 B

local common = require "core.common"
local syntax = {}
syntax.items = {}
local plain_text_syntax = { patterns = {}, symbols = {} }
function syntax.add(t)
table.insert(syntax.items, t)
end
local function find(string, field)
for i = #syntax.items, 1, -1 do
local t = syntax.items[i]
if common.match_pattern(string, t[field] or {}) then
return t
end
end
end
function syntax.get(filename, header)
return find(filename, "files")
or find(header, "headers")
or plain_text_syntax
end
return syntax