aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_go.lua
diff options
context:
space:
mode:
authorsammyette <38820196+TorchedSammy@users.noreply.github.com>2022-06-06 07:29:07 -0700
committerGitHub <noreply@github.com>2022-06-06 10:29:07 -0400
commitb0381360ba786433edf270bd0a6949000505e939 (patch)
tree1d167496a75893c3f9d0701a1e488b4008362e71 /plugins/language_go.lua
parent962374156e8a2657902dbe7d4de8831a2e6e8756 (diff)
downloadlite-xl-plugins-b0381360ba786433edf270bd0a6949000505e939.tar.gz
lite-xl-plugins-b0381360ba786433edf270bd0a6949000505e939.zip
language_go: small fixes (#95)
this makes sure that struct literals are always highlighted, not only when they aren't empty highlights single return types in functions highlights the `i` suffix in a number, which signifies a complex number highlights the type in type coercion syntax highlights iota as keyword2
Diffstat (limited to 'plugins/language_go.lua')
-rw-r--r--plugins/language_go.lua29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/language_go.lua b/plugins/language_go.lua
index f16ad72..b670eac 100644
--- a/plugins/language_go.lua
+++ b/plugins/language_go.lua
@@ -12,11 +12,11 @@ syntax.add {
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "`", "`", '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
- { pattern = "0[oO_][0-7]+", type = "number" },
- { pattern = "-?0x[%x_]+", type = "number" },
- { pattern = "-?%d+_%d", type = "number" },
- { pattern = "-?%d+[%d%.eE]*f?", type = "number" },
- { pattern = "-?%.?%d+f?", type = "number" },
+ { pattern = "0[oO_][0-7]+i?", type = "number" },
+ { pattern = "-?0x[%x_]+i?", type = "number" },
+ { pattern = "-?%d+_%di?", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*f?i?", type = "number" },
+ { pattern = "-?%.?%d+f?i?", type = "number" },
-- goto label
{ pattern = "^%s+()[%a_][%w%_]*()%s*:%s$", -- this is to fix `default:`
type = { "normal", "function", "normal" }
@@ -32,13 +32,14 @@ syntax.add {
{ pattern = "%[%]()[%a_][%w%_]*",
type = { "operator", "keyword2" }
},
- -- empty interface or struct
- { pattern = "[%a_][%w%_]*()%s*{%s*}",
- type = { "keyword2", "normal" }
+ -- type coerce
+ {
+ pattern = "%.%(()[%a_][%w_]*()%)",
+ type = { "normal", "keyword2", "normal" }
},
- -- return interface
- { pattern = "return()%s+()[%a_][%w%_]*()%s*{",
- type = { "keyword", "normal", "keyword2", "normal" }
+ -- struct literal
+ { pattern = "[%a_][%w%_]*()%s*{%s*",
+ type = { "keyword2", "normal" }
},
-- operators
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
@@ -123,6 +124,11 @@ syntax.add {
{ pattern = "[%a_][%w_]*()%s+()%[%]()[%a_][%w%_]*",
type = { "literal", "normal", "normal", "keyword2" }
},
+ -- single return type
+ {
+ pattern = "%)%s+%(?()[%a_][%w%_]*()%)?%s+%{",
+ type = { "normal", "keyword2", "normal" }
+ },
-- sub fields
{ pattern = "%.()[%a_][%w_]*",
type = { "normal", "literal" }
@@ -156,6 +162,7 @@ syntax.add {
["go"] = "keyword",
["fallthrough"] = "keyword",
["goto"] = "keyword",
+ ["iota"] = "keyword2",
["int"] = "keyword2",
["int64"] = "keyword2",
["int32"] = "keyword2",