From 21799d1c0f998318af34615be9d365c87fedc72a Mon Sep 17 00:00:00 2001 From: Ben Larisch Date: Sun, 12 Jun 2022 10:23:04 +0200 Subject: language_go: add syntax support for Go generic functions --- plugins/language_go.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/language_go.lua b/plugins/language_go.lua index e1c96b2..0532784 100644 --- a/plugins/language_go.lua +++ b/plugins/language_go.lua @@ -18,7 +18,8 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = ":=", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- function call + { pattern = "func()[%s].*[%a_][%w_]*()%f[%[(]", type = {"keyword", "function", "normal"} }, -- function statement { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { @@ -35,8 +36,8 @@ syntax.add { ["const"] = "keyword", ["package"] = "keyword", ["import"] = "keyword", - ["func"] = "keyword", ["var"] = "keyword", + ["func"] = "keyword", ["type"] = "keyword", ["interface"] = "keyword", ["select"] = "keyword", -- cgit v1.2.3 From 2d699dc7ee93e20323e7a9d40cf439b294d62e05 Mon Sep 17 00:00:00 2001 From: Ben Larisch Date: Sun, 12 Jun 2022 10:25:52 +0200 Subject: language_go: fmt file --- plugins/language_go.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/language_go.lua b/plugins/language_go.lua index 0532784..6e07827 100644 --- a/plugins/language_go.lua +++ b/plugins/language_go.lua @@ -6,21 +6,21 @@ syntax.add { files = { "%.go$" }, comment = "//", patterns = { - { pattern = "//.-\n", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { 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 = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = ":=", type = "operator" }, + { pattern = "//.-\n", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { 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 = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = ":=", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- function call { pattern = "func()[%s].*[%a_][%w_]*()%f[%[(]", type = {"keyword", "function", "normal"} }, -- function statement - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["if"] = "keyword", -- cgit v1.2.3 From 0e178ac90b2a0785925bb7679486aa3b5a9b40e0 Mon Sep 17 00:00:00 2001 From: Ben Larisch Date: Sun, 12 Jun 2022 11:15:53 +0200 Subject: language_go: mv func keyword to original line --- plugins/language_go.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_go.lua b/plugins/language_go.lua index 6e07827..199dc0a 100644 --- a/plugins/language_go.lua +++ b/plugins/language_go.lua @@ -36,8 +36,8 @@ syntax.add { ["const"] = "keyword", ["package"] = "keyword", ["import"] = "keyword", - ["var"] = "keyword", ["func"] = "keyword", + ["var"] = "keyword", ["type"] = "keyword", ["interface"] = "keyword", ["select"] = "keyword", -- cgit v1.2.3 From 467cc88b67317d12300a8c52444f4626dfdec1d0 Mon Sep 17 00:00:00 2001 From: Ben <89769190+benwalksaway@users.noreply.github.com> Date: Sun, 12 Jun 2022 14:07:41 +0200 Subject: language_go: function pattern: match only spaces Co-authored-by: Guldoman --- plugins/language_go.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_go.lua b/plugins/language_go.lua index 199dc0a..58c38c2 100644 --- a/plugins/language_go.lua +++ b/plugins/language_go.lua @@ -19,7 +19,7 @@ syntax.add { { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = ":=", type = "operator" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- function call - { pattern = "func()[%s].*[%a_][%w_]*()%f[%[(]", type = {"keyword", "function", "normal"} }, -- function statement + { pattern = "func()%s*[%a_][%w_]*()%f[%[(]", type = {"keyword", "function", "normal"} }, -- function statement { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { -- cgit v1.2.3