diff --git a/data/lib/red/presets.lua b/data/lib/red/presets.lua index 9ec6fcb..729a8cb 100644 --- a/data/lib/red/presets.lua +++ b/data/lib/red/presets.lua @@ -23,7 +23,8 @@ return { {"%.go$", { ts = 8, spaces_tab = false, - trim_spaces = true + trim_spaces = true, + syntax = "go", } }, {"%.py$", diff --git a/data/lib/red/syntax/c.lua b/data/lib/red/syntax/c.lua index fa448b8..ea76bad 100644 --- a/data/lib/red/syntax/c.lua +++ b/data/lib/red/syntax/c.lua @@ -49,7 +49,7 @@ local function number(ctx, txt, i) end local col = { - col = 0, + col = scheme.default, keywords = { { "!", "%%", "&&", "&", "(", ")", "*", "+", ",", "-", "/", ":", ";", "<", "=", ">", "?", "[", diff --git a/data/lib/red/syntax/go.lua b/data/lib/red/syntax/go.lua new file mode 100644 index 0000000..bf52ed5 --- /dev/null +++ b/data/lib/red/syntax/go.lua @@ -0,0 +1,86 @@ +local scheme = require "red/syntax/scheme" + +local function number(ctx, txt, i) + local n = '' + local start = i + while txt[i] and txt[i]:find("[0-9]") do + n = n .. txt[i] + i = i + 1 + end + if n ~= '' then return i - start end + return false +end + +local col = { + col = scheme.default, + keywords = { + { "<-", "+", "&", "(", ")", "-", "|", "<", "[", "]", "*", "^", + ">", "{", "}", "/", "=", ",", ";", "%", "!", ".", ":", + col = scheme.operator }, + { + "break", "case", "chan", "const", "continue", "default", + "defer", "else", "fallthrough", "for", "func", "go", + "goto", "if", "import", "interface", "map", "package", + "range", "return", "select", "struct", "switch", "type", + "var", + col = scheme.keyword, word = true + }, + { + "uint8", "uint16", "uint32", "uint64", "int8", + "int16", "int32", "int64", "float32", "float64", + "byte", "uint", "int", "float", "uintptr", + "string", "bool", + + "nil", "true", "false", "iota", "cap", "close", + "closed", "len", "make", "new", "panic", + "panicln", "print", + col = scheme.lib, word = true, + }, + { + "tar", "zip", "bufio", "bytes", "cmd", "compress", + "container", "crypto", "database", "debug", "encoding", + "errors", "expvar", "flag", "fmt", "hash", "html", + "image", "suffixarray", "race", "singleflight", + "syscall", "testenv", "trace", "io", "log", "math", + "mime", "net", "os", "path", "reflect", "regexp", + "runtime", "sort", "strconv", "strings", "sync", + "testing", "text", "time", "unicode", "unsafe", + "vendor", "unicode", "functions", "init", + col = scheme.lib, word = true, + }, + { number, col = scheme.number }, + }, + { -- string + start = "`", + stop = "`", + col = scheme.string, + }, + { -- string + start = '"', + stop = '"', + keywords = { + { '\\"', '\\\\' }, + }, + col = scheme.string, + }, + { -- string + start = "'", + stop = "'", + keywords = { + { "\\'", "\\\\" }, + }, + col = scheme.string, + }, + { -- comment + start = "/*"; + stop = '*/'; + col = scheme.comment, + }, + { -- comment + start = "//"; + stop = '\n'; + col = scheme.comment, + }, +} + +return col diff --git a/data/lib/red/syntax/lua.lua b/data/lib/red/syntax/lua.lua index e94f969..a6e1efa 100644 --- a/data/lib/red/syntax/lua.lua +++ b/data/lib/red/syntax/lua.lua @@ -38,7 +38,7 @@ local function number(ctx, txt, i) end local col = { - col = 0, + col = scheme.default, keywords = { { "(", ")", "{", "}", "[", "]", ".", ",", ";", ":", "..", "...", "==", "~=", "<=", "=>", ">", "<", "+", "-", diff --git a/data/lib/red/syntax/markdown.lua b/data/lib/red/syntax/markdown.lua index c509ab2..877151c 100644 --- a/data/lib/red/syntax/markdown.lua +++ b/data/lib/red/syntax/markdown.lua @@ -22,7 +22,7 @@ local function numbersect(ctx, txt, pos, epos) end local col = { - col = 0, + col = scheme.default, keywords = { { '\\*', '\\#', '\\-', '\\\\' }, }, diff --git a/data/lib/red/syntax/python.lua b/data/lib/red/syntax/python.lua index 6c51a97..774da2f 100644 --- a/data/lib/red/syntax/python.lua +++ b/data/lib/red/syntax/python.lua @@ -12,7 +12,7 @@ local function number(ctx, txt, i) end local col = { - col = 0, + col = scheme.default, keywords = { { ":", ".", ">", "<", "+", "-", "*", "/", "%", "=", "!=", "==", "{", "}", "(", ")", "[", "]", ",", ";",