mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
* highlighter: Fix region & pattern detection * syntax/sh: Highlight upper case options too * syntax/c(pp): Try to synchronize the rules to lower the maintenance effort * syntax/ruby: Fix explicit filename detection in directories * highlighter: Respect skip rules in regions * syntax/sh: Fix parameter expansion, cond. flags and generalize filename via "" * syntax/php|vi: Correct strings in comments to comments only Additionally improve vimscript comment handling. * highlighter: Remove problematic start|end check in find(all)Index() ...and additionally remove recursive region end detection
56 lines
2.1 KiB
YAML
56 lines
2.1 KiB
YAML
filetype: c
|
|
|
|
detect:
|
|
filename: "(\\.(c|C)$|\\.(h|H)$|\\.ii?$|\\.(def)$)"
|
|
|
|
rules:
|
|
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
|
|
- type: "\\b(float|double|bool|char|int|short|long|enum|void|struct|union|typedef|(un)?signed|inline)\\b"
|
|
- type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b"
|
|
- type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b"
|
|
- statement: "\\b(auto|volatile|register|restrict|static|const|extern)\\b"
|
|
- statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
|
|
- statement: "\\b(goto|continue|break|return)\\b"
|
|
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
|
# GCC builtins
|
|
- statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
|
|
- statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
|
# Operator Color
|
|
- symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(sizeof)\\b"
|
|
- symbol.brackets: "[(){}]|\\[|\\]"
|
|
# Integer Constants
|
|
- constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
|
|
# Decimal Floating Constants
|
|
- constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)"
|
|
# Hexadecimal Floating Constants
|
|
- constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
|
|
- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)"
|
|
|
|
- constant.string:
|
|
start: "\""
|
|
end: "\""
|
|
skip: "\\\\."
|
|
rules:
|
|
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"
|
|
|
|
- constant.string:
|
|
start: "'"
|
|
end: "'"
|
|
skip: "\\\\."
|
|
rules:
|
|
- error: "..+"
|
|
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"
|
|
|
|
- comment:
|
|
start: "//"
|
|
end: "$"
|
|
rules:
|
|
- todo: "(TODO|XXX|FIXME):?"
|
|
|
|
- comment:
|
|
start: "/\\*"
|
|
end: "\\*/"
|
|
rules:
|
|
- todo: "(TODO|XXX|FIXME):?"
|
|
|