From 59dc6b57108b5e2c6c55b8dd222d697ab0bdcf0a Mon Sep 17 00:00:00 2001 From: Lukasz <112113+detomastah@users.noreply.github.com> Date: Sat, 14 Mar 2026 13:36:41 +0100 Subject: [PATCH] slim template language syntax highlighting --- plugins/language_slim.lua | 261 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 plugins/language_slim.lua diff --git a/plugins/language_slim.lua b/plugins/language_slim.lua new file mode 100644 index 00000000..6d9de751 --- /dev/null +++ b/plugins/language_slim.lua @@ -0,0 +1,261 @@ +-- mod-version:3 +local syntax = require "core.syntax" + +syntax.add { + name = "Slim template language", + files = { "%.slim$", "%.skim$" }, + comment = "/", + patterns = { + { + -- Embedded engine blocks (indented content until next non-indented line). + -- Matches: + -- ruby: + -- body { color: red } + pattern = { "^%s*ruby:%s*[^\n]*", "^%S" }, + syntax = ".rb", + type = "function", + }, + { + -- Matches: + -- css: + -- body { color: red } + pattern = { "^%s*css:%s*[^\n]*", "^%S" }, + syntax = ".css", + type = "function", + }, + { + -- Matches: + -- sass: + -- $c: #fff + -- body + -- color: $c + pattern = { "^%s*sass:%s*[^\n]*", "^%S" }, + syntax = ".sass", + type = "function", + }, + { + -- Matches: + -- styl: + -- body + -- color red + pattern = { "^%s*styl:%s*[^\n]*", "^%S" }, + syntax = ".styl", + type = "function", + }, + { + -- Matches: + -- scss: + -- $c: #fff; + -- body { color: $c; } + pattern = { "^%s*scss:%s*[^\n]*", "^%S" }, + syntax = ".scss", + type = "function", + }, + { + -- Matches: + -- coffee: + -- alert "hi" + pattern = { "^%s*coffee:%s*[^\n]*", "^%S" }, + syntax = ".coffee", + type = "function", + }, + { + -- Matches: + -- javascript: + -- console.log("hi") + pattern = { "^%s*javascript:%s*[^\n]*", "^%S" }, + syntax = ".js", + type = "function", + }, + + { + -- Slim block comment: a slash line with nested indented lines. + -- Matches: + -- / This is a comment block + -- still commented + regex = "^%s*/%S[^\n]*$", + type = "comment", + }, + { + -- Slim line comment: slash at line start, no indentation block. + -- Matches: + -- /just a comment + pattern = { "^%s*/%s*", "\n" }, + -- regex = "^%s*/%S[^\n]*$", + type = "comment", + }, + + { + -- Escaped content block: literal text starting with | or ' then space/tab. + -- Matches: + -- | literal not a tag #{user.name} + -- continued line + pattern = { "^%s*[|']%s", "^%S" }, + type = "normal", + syntax = ".html", + }, + + { + -- Ruby logic line (control flow): lines starting with "-". + -- Matches: + -- - if user + -- - user.items.each do |i| + pattern = { "^%s*%-%s*", "\n" }, + syntax = ".rb", + type = "function", + }, + { + -- Ruby output line: lines starting with "=" or "==". + -- Matches: + -- = user.name + -- == render("partial") + pattern = { "^%s*==?%s*", "\n" }, + syntax = ".rb", + type = "function", + }, + { + -- Ruby interpolation inside text: #{ ... } (best-effort; nested braces not handled). + -- Matches: + -- | Hello #{current_user.name}! + regex = { "(?