From d6d0b44fa523fd2e5712763ca4488584c01ac148 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 16 Feb 2017 19:27:32 -0500 Subject: [PATCH] Add markdown, objc, zsh --- syntax_files/markdown.yaml | 49 ++++++++++++++++++++++++++++++++ syntax_files/objc.yaml | 57 ++++++++++++++++++++++++++++++++++++++ syntax_files/zsh.yaml | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 syntax_files/markdown.yaml create mode 100644 syntax_files/objc.yaml create mode 100644 syntax_files/zsh.yaml diff --git a/syntax_files/markdown.yaml b/syntax_files/markdown.yaml new file mode 100644 index 0000000..bcf629d --- /dev/null +++ b/syntax_files/markdown.yaml @@ -0,0 +1,49 @@ +filetype: markdown + +detect: + filename: "\\.(md|mkd|mkdn|markdown)$" + +rules: + # Tables (Github extension) + - type: ".*[ :]\\|[ :].*" + + # quotes + - statement: "^>.*" + + # Emphasis + - type: "(^|[[:space:]])(_[^ ][^_]*_|\\*[^ ][^*]*\\*)" + + # Strong emphasis + - type: "(^|[[:space:]])(__[^ ][^_]*__|\\*\\*[^ ][^*]*\\*\\*)" + + # strike-through + - type: "(^|[[:space:]])~~[^ ][^~]*~~" + + # horizontal rules + - special: "^(---+|===+|___+|\\*\\*\\*+)\\s*$" + + # headlines + - special: "^#{1,6}.*" + + # lists + - identifier: "^[[:space:]]*[\\*+-] |^[[:space:]]*[0-9]+\\. " + + # misc + - preproc: "(\\(([CcRr]|[Tt][Mm])\\)|\\.{3}|(^|[[:space:]])\\-\\-($|[[:space:]]))" + + # links + - constant: "\\[[^]]+\\]" + - constant: "\\[([^][]|\\[[^]]*\\])*\\]\\([^)]+\\)" + + # images + - underlined: "!\\[[^][]*\\](\\([^)]+\\)|\\[[^]]+\\])" + + # urls + - underlined: "https?://[^ )>]+" + + - special: "^```$" + + - special: + start: "`" + end: "`" + rules: [] diff --git a/syntax_files/objc.yaml b/syntax_files/objc.yaml new file mode 100644 index 0000000..9392134 --- /dev/null +++ b/syntax_files/objc.yaml @@ -0,0 +1,57 @@ +filetype: objective-c + +detect: + filename: "\\.(m|mm|h)$" + +rules: + - type: "\\b(float|double|CGFloat|id|bool|BOOL|Boolean|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline|Class|SEL|IMP|NS(U)?Integer)\\b" + - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" + - type: "\\b[A-Z][A-Z][[:alnum:]]*\\b" + - type: "\\b[A-Za-z0-9_]*_t\\b" + - type: "\\bdispatch_[a-zA-Z0-9_]*_t\\b" + + - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" "__unused" "_Nonnull" "_Nullable" "__block" "__builtin.*" + - statement: "\\b(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\\b" + - statement: "\\b(for|if|while|do|else|case|default|switch)\\b" + - statement: "\\b(try|throw|catch|operator|new|delete)\\b" + - statement: "\\b(goto|continue|break|return)\\b" + - statement: "\\b(nonatomic|atomic|readonly|readwrite|strong|weak|assign)\\b" + - statement: "@(encode|end|interface|implementation|class|selector|protocol|synchronized|try|catch|finally|property|optional|required|import|autoreleasepool)" + + - preproc: "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$" + - preproc: "__[A-Z0-9_]*__" + + - special: "^[[:space:]]*[#|@][[:space:]]*(import|include)[[:space:]]*[\"|<].*\/?[>|\"][[:space:]]*$" + + - statement: "[.:;,+*|=!\\%\\[\\]]" "<" ">" "/" "-" "&" + + - constant.number: "\\b(-?)?[0-9]+\\b" "\\b\\[0-9]+\\.[0-9]+\\b" "\\b0x[0-9A-F]+\\b" + - constant: "@\\[(\\\\.|[^\\]])*\\]" "@\\{(\\\\.|[^\\}])*\\}" "@\\((\\\\.|[^\\)])*\\)" + - constant: "\\b<(\\\\.[^\\>])*\\>\\b" + - constant: "\\b(nil|NULL|YES|NO|TRUE|true|FALSE|false|self)\\b" + - constant: "\\bk[[:alnum]]*\\b" + - constant.string: "'.'" + + - constant.string: + start: "@\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "(TODO|XXX|FIXME):?" diff --git a/syntax_files/zsh.yaml b/syntax_files/zsh.yaml new file mode 100644 index 0000000..b658314 --- /dev/null +++ b/syntax_files/zsh.yaml @@ -0,0 +1,50 @@ +filetype: zsh + +detect: + filename: "(\\.zsh$|\\.?(zshenv|zprofile|zshrc|zlogin|zlogout)$)" + header: "^#!.*/(env +)?zsh( |$)" + +rules: + ## Numbers + - constant.number: "\\b[0-9]+\\b" + + ## Conditionals and control flow + - statement: "\\b(always|break|bye|case|continue|disown|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\\b" + + - statement: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)" + ## Conditional flags + - special: "-[Ldefgruwx]\\b" + - special: "-(eq|ne|gt|lt|ge|le|s|n|z)\\b" + + ## Bash-inherited + - statement: "\\b((un)?alias|bindkey|builtin|cd|declare|eval|exec|export|jobs|let|popd|pushd|set|source|typeset|umask|unset)\\b" + ## ZSH-specific + - type: "\\b(add-zsh-hook|autoload|chdir|compinit|dirs|(dis|en)able|echotc|emulate|print|prompt(init)?|(un)?setopt|zle|zmodload|zstyle|whence)\\b" + + ## Common linux commands + - statement: "\\b((g|ig)?awk|find|\\w{0,4}grep|kill|killall|\\w{0,4}less|make|pkill|sed|tar)\\b" + + ## Coreutils commands + - statement: "\\b(base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|dd|df|dir|dircolors|dirname|du|echo|env|expand|expr|factor|false|fmt|fold|head|hostid|id|install|join|link|ln|logname|ls|md5sum|mkdir|mkfifo|mknod|mktemp|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|pr|printenv|printf|ptx|pwd|readlink|realpath|rm|rmdir|runcon|seq|(sha1|sha224|sha256|sha384|sha512)sum|shred|shuf|sleep|sort|split|stat|stdbuf|stty|sum|sync|tac|tail|tee|test|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|users|vdir|wc|who|whoami|yes)\\b" + + ## Function definition + - identifier: "^\\s+(function\\s+)[0-9A-Z_]+\\s+\\(\\)" # (i) + + ## Variables + - identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" #(i) + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'" + end: "'" + rules: [] + + - comment: + start: "#" + end: "$" + rules: []