aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/language_nim.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/plugins/language_nim.lua b/plugins/language_nim.lua
index d7726d1..425544e 100644
--- a/plugins/language_nim.lua
+++ b/plugins/language_nim.lua
@@ -88,14 +88,37 @@ for _, type in ipairs(standard_generic_types) do
table.insert(patterns, { pattern = type.." +%f[%w]", type = "keyword2" })
end
+local function string_pattern(start, stop, syntax)
+ return {
+ pattern = { start, stop, '\\' },
+ type = "string",
+ syntax = syntax and {
+ patterns = syntax,
+ symbols = {},
+ } or nil
+ }
+end
+
+local interpolation_syntax = {
+ { pattern = { '{{', '}}' }, type = "string" },
+ { pattern = { '{', '}', '\\' }, type = "keyword2", syntax = ".nim" },
+ { pattern = "[%S][%w]*", type = "string" },
+}
+
local user_patterns = {
-- comments
{ pattern = { "##?%[", "]##?" }, type = "comment" },
{ pattern = "##?.-\n", type = "comment" },
-- strings and chars
- { pattern = { '"', '"', '\\' }, type = "string" },
- { pattern = { '"""', '"""[^"]' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "literal" },
+ string_pattern('"""', '"""%f[^"]'),
+ string_pattern('"' , '"' ),
+ string_pattern('\\"', '\\"' ), -- For highlighting strings inside iterpolated blocks
+ -- string interpolation
+ string_pattern('%&"""' , '"""%f[^"]', interpolation_syntax),
+ string_pattern('fmt"""', '"""%f[^"]', interpolation_syntax),
+ string_pattern('%&"' , '"' , interpolation_syntax),
+ string_pattern('fmt"' , '"' , interpolation_syntax),
-- function calls
{ pattern = "[a-zA-Z][a-zA-Z0-9_]*%f[(]", type = "function" },
-- identifiers