From 887b40b9d43f89a57646fb3e400f6875c4345f89 Mon Sep 17 00:00:00 2001 From: Sathish Manohar Date: Sat, 15 Oct 2022 02:31:50 +0530 Subject: Add language plugin for ERB files (#131) * Add language plugin for ERB files erb files typically has filename.html.erb extension they contain html markup and embedded ruby code this file should properly syntax highlight both html and ruby parts * merge html/htm in filetype check --- plugins/language_erb.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 plugins/language_erb.lua diff --git a/plugins/language_erb.lua b/plugins/language_erb.lua new file mode 100644 index 0000000..e63c7b0 --- /dev/null +++ b/plugins/language_erb.lua @@ -0,0 +1,55 @@ +-- mod-version:2 +local syntax = require "core.syntax" + +syntax.add { + name = "html-eruby", + files = { "%.html?%.erb$", "%.erb$" }, + block_comment = { "" }, + patterns = { + { + pattern = { + "<%s*[sS][cC][rR][iI][pP][tT]%f[%s>].->", + "<%s*/%s*[sS][cC][rR][iI][pP][tT]%s*>" + }, + syntax = ".js", + type = "function" + }, + { + pattern = { + "<%s*[sS][tT][yY][lL][eE]%f[%s>].->", + "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" + }, + syntax = ".css", + type = "function" + }, + { + pattern = { + "<%%", + "%%>" + }, + syntax = ".rb", + type = "function" + }, + { + pattern = { + "<%%=", + "%%>" + }, + syntax = ".rb", + type = "function" + }, + { pattern = { "" }, type = "comment" }, + { pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "0x[%da-fA-F]+", type = "number" }, + { pattern = "-?%d+[%d%.]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "%f[^<]![%a_][%w_]*", type = "keyword2" }, + { pattern = "%f[^<][%a_][%w_]*", type = "function" }, + { pattern = "%f[^<]/[%a_][%w_]*", type = "function" }, + { pattern = "[%a_][%w_]*", type = "keyword" }, + { pattern = "[/<>=]", type = "operator" }, + }, + symbols = {}, +} -- cgit v1.2.3