Repository navigation
|
Hi! I started using Micro today and I am really enjoying it so far. One thing I noticed is that in JSON files, property keys (names) and string values are rendered with the same color, making them hard to distinguish. Is there a plugin, custom syntax file, or recommended method to highlight JSON keys and string values in different colors? Thanks! |
Replies: 1 comment 1 reply
|
No plugin is required, but a colorscheme alone cannot distinguish them with the current built-in JSON syntax: both keys and string values are initially matched as constant.string.
filetype: json
detect:
filename: "\\.json$"
header: "^\\s*\\{"
rules:
- constant.number: "\\b-?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?\\b"
- constant: "\\b(null|true|false)\\b"
- constant.string: '"(\\.|[^"\\])*"'
- statement: '"(\\.|[^"\\])*"[[:space:]]*:'
- constant.specialChar: '\\(u[0-9a-fA-F]{4}|["\\/bfnrt])'Micro applies later pattern rules over earlier ones, so string values remain |
No plugin is required, but a colorscheme alone cannot distinguish them with the current built-in JSON syntax: both keys and string values are initially matched as constant.string.
A practical workaround is to override the JSON syntax definition. Create:
~/.config/micro/syntax/json.yamlMicro applies later pattern rules over earlier ones, so string values re…