aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/language_go.lua109
1 files changed, 109 insertions, 0 deletions
diff --git a/plugins/language_go.lua b/plugins/language_go.lua
index 1ce311e..f16ad72 100644
--- a/plugins/language_go.lua
+++ b/plugins/language_go.lua
@@ -5,6 +5,7 @@ syntax.add {
name = "Go",
files = { "%.go$" },
comment = "//",
+ block_comment = {"/*", "*/"},
patterns = {
{ pattern = "//.-\n", type = "comment" },
{ pattern = { "/%*", "%*/" }, type = "comment" },
@@ -16,9 +17,117 @@ syntax.add {
{ pattern = "-?%d+_%d", type = "number" },
{ pattern = "-?%d+[%d%.eE]*f?", type = "number" },
{ pattern = "-?%.?%d+f?", type = "number" },
+ -- goto label
+ { pattern = "^%s+()[%a_][%w%_]*()%s*:%s$", -- this is to fix `default:`
+ type = { "normal", "function", "normal" }
+ },
+ { pattern = "^%s*[%a_][%w%_]*()%s*:%s$",
+ type = { "function", "normal" }
+ },
+ -- pointer, generic and reference type
+ { pattern = "[%*~&]()[%a_][%w%_]*",
+ type = { "operator", "keyword2" }
+ },
+ -- slice type
+ { pattern = "%[%]()[%a_][%w%_]*",
+ type = { "operator", "keyword2" }
+ },
+ -- empty interface or struct
+ { pattern = "[%a_][%w%_]*()%s*{%s*}",
+ type = { "keyword2", "normal" }
+ },
+ -- return interface
+ { pattern = "return()%s+()[%a_][%w%_]*()%s*{",
+ type = { "keyword", "normal", "keyword2", "normal" }
+ },
+ -- operators
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
{ pattern = ":=", type = "operator" },
+ -- function calls
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "%.()[%a_][%w_]*%f[(]",
+ type = { "normal", "function" }
+ },
+ -- type declaration
+ { pattern = "type()%s+()[%a_][%w%_]*",
+ type = { "keyword", "normal", "keyword2" }
+ },
+ -- variable declaration
+ { pattern = "var()%s+()[%a_][%w%_]*",
+ type = { "keyword", "normal", "symbol" }
+ },
+ -- goto
+ { pattern = "goto()%s+()[%a_][%w%_]*",
+ type = { "keyword", "normal", "function" }
+ },
+ -- if fix
+ { pattern = "if()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- for fix
+ { pattern = "for()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- return fix
+ { pattern = "return()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- range fix
+ { pattern = "range()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- func fix
+ { pattern = "func()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- switch fix
+ { pattern = "switch()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- case fix
+ { pattern = "case()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- break fix
+ { pattern = "break()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- continue fix
+ { pattern = "continue()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- package fix
+ { pattern = "package()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- go fix
+ { pattern = "go()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- chan fix
+ { pattern = "chan()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- defer fix
+ { pattern = "defer()%s+%f[%a_]",
+ type = { "keyword", "normal" }
+ },
+ -- field declaration
+ { pattern = "[%a_][%w%_]*()%s*():%s*%f[%w%p]",
+ type = { "function", "normal", "operator" }
+ },
+ -- parameters or declarations
+ { pattern = "[%a_][%w%_]*()%s+()[%*~&]?()[%a_][%w%_]*",
+ type = { "literal", "normal", "operator", "keyword2" }
+ },
+ { pattern = "[%a_][%w_]*()%s+()%[%]()[%a_][%w%_]*",
+ type = { "literal", "normal", "normal", "keyword2" }
+ },
+ -- sub fields
+ { pattern = "%.()[%a_][%w_]*",
+ type = { "normal", "literal" }
+ },
+ -- every other symbol
{ pattern = "[%a_][%w_]*", type = "symbol" },
},
symbols = {