aboutsummaryrefslogtreecommitdiff
path: root/data/core/syntax.lua
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-05-07 10:27:37 +0100
committerrxi <rxi@users.noreply.github.com>2020-05-07 10:27:37 +0100
commit3057786ce2bbd8cc623e1597718c200945cc6d82 (patch)
treea7a686aee774326b2ef737d0aff71562f9515d6e /data/core/syntax.lua
parente551052e9102ce02ff4f3a55c5e1af4f001cc585 (diff)
downloadpragtical-3057786ce2bbd8cc623e1597718c200945cc6d82.tar.gz
pragtical-3057786ce2bbd8cc623e1597718c200945cc6d82.zip
Moved `matches_pattern` from `syntax` to `common`
Diffstat (limited to 'data/core/syntax.lua')
-rw-r--r--data/core/syntax.lua16
1 files changed, 3 insertions, 13 deletions
diff --git a/data/core/syntax.lua b/data/core/syntax.lua
index 08db473c..ddc1b2f2 100644
--- a/data/core/syntax.lua
+++ b/data/core/syntax.lua
@@ -1,21 +1,11 @@
-local syntax = {}
+local common = require "core.common"
+local syntax = {}
syntax.items = {}
local plain_text_syntax = { patterns = {}, symbols = {} }
-local function matches_pattern(text, pattern)
- if type(pattern) == "string" then
- return text:find(pattern)
- end
- for _, p in ipairs(pattern) do
- if matches_pattern(text, p) then return true end
- end
- return false
-end
-
-
function syntax.add(t)
table.insert(syntax.items, t)
end
@@ -24,7 +14,7 @@ end
function syntax.get(filename)
for i = #syntax.items, 1, -1 do
local t = syntax.items[i]
- if matches_pattern(filename, t.files) then
+ if common.matches_pattern(filename, t.files) then
return t
end
end