diff options
author | Guldoman <giulio.lettieri@gmail.com> | 2022-06-12 03:33:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 03:33:07 +0200 |
commit | ac2e5251fdf4feed9e97a619f525abd8179c0512 (patch) | |
tree | 28746b5bd50e8c048b263699ac60c18be26c6f19 | |
parent | 7df41835bc47ca905467256e146d76dda2bb172f (diff) | |
parent | 9f7398e2a926e188919b23dd68dd60df2da6fb1c (diff) | |
download | lite-xl-plugins-ac2e5251fdf4feed9e97a619f525abd8179c0512.tar.gz lite-xl-plugins-ac2e5251fdf4feed9e97a619f525abd8179c0512.zip |
Merge pull request #98 from KatrinaKitten/master
Add support for SQL strings to language_php
-rw-r--r-- | plugins/language_php.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/language_php.lua b/plugins/language_php.lua index 83bd901..5ef4f22 100644 --- a/plugins/language_php.lua +++ b/plugins/language_php.lua @@ -10,6 +10,15 @@ local syntax = require "core.syntax" require "plugins.language_css" require "plugins.language_js" +-- generate SQL string marker regex +local sql_markers = { 'create', 'select', 'insert', 'update', 'replace', 'delete', 'drop', 'alter' } +local sql_regex = {} +for _,marker in ipairs(sql_markers) do + table.insert(sql_regex, marker) + table.insert(sql_regex, string.upper(marker)) +end +sql_regex = table.concat(sql_regex, '|') + -- define the core php syntax coloring syntax.add { name = "PHP Source", @@ -24,6 +33,17 @@ syntax.add { { pattern = "//.-\n", type = "comment" }, { pattern = "#.-\n", type = "comment" }, { pattern = { "/%*", "%*/" }, type = "comment" }, + -- SQL strings + { + regex = { '"(?=(?:'..sql_regex..')\\s+)', '"', '\\' }, + syntax = '.sql', + type = "string" + }, + { + regex = { '\'(?=(?:'..sql_regex..')\\s+)', '\'', '\\' }, + syntax = '.sql', + type = "string" + }, -- The '\\' is for escaping to work on " or ' { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "'", "'", '\\' }, type = "string" }, |