2018-04-17 16:20:22 +03:00
|
|
|
package cfg
|
|
|
|
|
|
|
|
type LanguageSyntaxConfig struct {
|
2018-04-21 20:58:21 +03:00
|
|
|
Syntax map[string]*SyntaxCriteria `toml:"syntax"`
|
2018-04-17 16:20:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type DefaultSyntax map[string]string
|
|
|
|
|
|
|
|
var DefaultSyntaxSet = DefaultSyntax{}
|
|
|
|
|
|
|
|
func RegisterSyntax(name string, s string) {
|
|
|
|
DefaultSyntaxSet[name] = s
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2018-04-22 20:38:01 +03:00
|
|
|
// TOML
|
|
|
|
RegisterSyntax("toml", `[syntax.toml]
|
|
|
|
[syntax.declaration]
|
|
|
|
colouring = 0xf8f273
|
|
|
|
pattern = '(\[)(.*)(\])'
|
|
|
|
|
|
|
|
[syntax.identifier]
|
|
|
|
colouring = 0xf0a400
|
|
|
|
pattern = '\b([a-z]|[A-Z])+(_|([a-z]|[A-Z])+)*\b'
|
|
|
|
|
|
|
|
[syntax.symbol]
|
2018-04-22 20:56:47 +03:00
|
|
|
match = ["="]
|
2018-04-22 20:38:01 +03:00
|
|
|
colouring = 0xf8f273
|
|
|
|
`)
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
// C LANGUAGE SYNTAX HIGHLIGHTING
|
|
|
|
|
2018-04-17 16:20:22 +03:00
|
|
|
RegisterSyntax("c", `[syntax.c]
|
|
|
|
[syntax.type]
|
|
|
|
colouring = 0xf8f273
|
|
|
|
match = [
|
|
|
|
"int", "char", "bool", "float", "double", "void",
|
|
|
|
"uint8_t", "uint16_t", "uint32_t", "uint64_t",
|
2018-04-17 22:52:33 +03:00
|
|
|
"int8_t", "int16_t", "int32_t", "int64_t", "const"
|
2018-04-17 16:20:22 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
[syntax.keyword]
|
|
|
|
colouring = 0xf0a400
|
|
|
|
match = [
|
|
|
|
"for", "break", "if", "else", "continue", "return",
|
2018-04-21 20:58:21 +03:00
|
|
|
"goto", "extern", "const", "typedef",
|
2018-04-17 22:52:33 +03:00
|
|
|
"struct", "union", "register", "enum",
|
|
|
|
"do", "static", "sizeof", "volatile", "unsigned",
|
2018-04-21 20:58:21 +03:00
|
|
|
"switch", "case", "default"
|
2018-04-17 16:20:22 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
[syntax.string_literal]
|
|
|
|
colouring = 0x4b79fc
|
|
|
|
pattern = "\"([^\\\"]|\\.)*\""
|
|
|
|
|
|
|
|
[syntax.directive]
|
|
|
|
colouring = 0xf0a400
|
|
|
|
pattern = "^\\s*#\\s*include\\s+(?:<[^>]*>|\"[^\"]*\")\\s*"
|
|
|
|
|
2018-04-21 21:11:41 +03:00
|
|
|
[syntax.symbol]
|
|
|
|
colouring = 0xf0a400
|
|
|
|
match = [
|
|
|
|
"+=", "-=", "*=", "/=", ">>", "<<", "==", "!=",
|
|
|
|
">=", "<=", "||", "&&",
|
|
|
|
"=", ":", ";", "*", "&", "+", "-", "/", "%",
|
|
|
|
"^", "#", "!", "@", "<", ">", ".", ","
|
|
|
|
]
|
|
|
|
|
2018-04-17 16:20:22 +03:00
|
|
|
[syntax.comment]
|
|
|
|
colouring = 0x4b79fc
|
|
|
|
pattern = '//.*'`)
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
// GO LANGUAGE SYNTAX HIGHLIGHTING
|
|
|
|
|
2018-04-17 16:20:22 +03:00
|
|
|
RegisterSyntax("go", `[syntax.go]
|
2018-04-17 22:52:33 +03:00
|
|
|
[syntax.keyword]
|
2018-04-17 16:20:22 +03:00
|
|
|
colouring = 0xf0a400
|
|
|
|
match = [
|
2018-04-17 22:52:33 +03:00
|
|
|
"break", "default", "func", "interface", "select",
|
|
|
|
"case", "defer", "go", "map", "struct",
|
|
|
|
"chan", "else", "goto", "package", "switch",
|
|
|
|
"const", "fallthrough", "if", "range", "type",
|
|
|
|
"continue", "for", "import", "return", "var",
|
2018-04-17 16:20:22 +03:00
|
|
|
]
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
[syntax.type]
|
2018-04-17 16:20:22 +03:00
|
|
|
colouring = 0xf8f273
|
|
|
|
match = [
|
2018-04-17 22:52:33 +03:00
|
|
|
"int", "string", "uint", "rune",
|
2018-04-17 16:20:22 +03:00
|
|
|
"int8", "int16", "int32", "int64",
|
|
|
|
"uint8", "uint16", "uint32", "uint64",
|
2018-04-17 22:52:33 +03:00
|
|
|
"byte", "float32", "float64", "complex64",
|
|
|
|
"complex128", "uintptr",
|
2018-04-17 16:20:22 +03:00
|
|
|
]
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
[syntax.comment]
|
2018-04-17 16:20:22 +03:00
|
|
|
colouring = 0x4b79fc
|
|
|
|
pattern = '//.*'
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
[syntax.string_literal]
|
2018-04-17 16:20:22 +03:00
|
|
|
colouring = 0x4b79fc
|
|
|
|
pattern = "\"([^\\\"]|\\.)*\""
|
|
|
|
|
2018-04-17 22:52:33 +03:00
|
|
|
[syntax.symbol]
|
2018-04-17 16:20:22 +03:00
|
|
|
colouring = 0xf0a400
|
|
|
|
match = [
|
2018-04-21 21:14:04 +03:00
|
|
|
"+=", "-=", "*=", "/=", ">>", "<<", "==", "!=", ":=",
|
2018-04-21 21:11:41 +03:00
|
|
|
">=", "<=", "||", "&&",
|
2018-04-17 16:20:22 +03:00
|
|
|
"=", ":", ";", "*", "&", "+", "-", "/", "%",
|
|
|
|
"^", "#", "!", "@", "<", ">", ".", ","
|
|
|
|
]`)
|
2018-04-17 23:04:18 +03:00
|
|
|
|
|
|
|
RegisterSyntax("md", `[syntax.md]
|
|
|
|
[syntax.header]
|
|
|
|
colouring = 0xff00ff
|
|
|
|
pattern = '(?m)^#{1,6}.*'
|
|
|
|
`)
|
|
|
|
|
|
|
|
// your syntax here!
|
2018-04-17 16:20:22 +03:00
|
|
|
}
|