-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add syntax highlighting rules for .properties files #3976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add syntax highlighting rules for .properties files #3976
Conversation
Andriamanitra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a couple of small issues:
- All
=are being highlighted as strings. - The boolean highlights don't work on the right side of a
=. - In the example file on Wikipedia there are line continuations by escaping the newline but I don't think we need to worry about that (not sure if it's even possible within the constraints of the syntax highlighter).
At first I was thinking we could do something like this but limit-group: doesn't work with rules: so this is unfortunately not an option. 😞
- constant.string:
start: "[=:]"
end: "$"
limit-group: statement
skip: "\\\\$"
rules:
- constant.specialChar: "\\\\."
- constant: "\\b(true|false|TRUE|FALSE|yes|no|ON|OFF)\\b"Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
|
@Andriamanitra Thanks for the suggestions. I testing the syntax with the following file ############################################
# COMMENTS
############################################
# Single-line comment
! Alternate comment style
# TODO: comment with keyword
# FIXME: another keyword
# Comment with symbols !@#$%^&*()
############################################
# BASIC KEY-VALUE PAIRS
############################################
string.simple=hello
string.with.spaces=hello world
string.with.colon=value:with:colons
string.with.equals=value=with=equals
string.with.hash=value # inline comment-like text
string.empty=
string.whitespace= padded value
############################################
# QUOTED STRINGS (SIMULATED)
############################################
string.doubleQuoted="double quoted value"
string.singleQuoted='single quoted value'
string.mixedQuotes="He said 'hello'"
string.escapedQuotes=\"escaped quote\"
############################################
# ESCAPE SEQUENCES
############################################
escape.newline=Line1\nLine2
escape.tab=Column1\tColumn2
escape.backslash=C:\\Program Files\\App
escape.unicode=\u03A9 \u2603 \u2764
escape.special=\r \f \b
############################################
# NUMBERS
############################################
number.int=42
number.negative=-7
number.zero=0
number.float=3.14159
number.scientific=6.022e23
number.hex=0xFF
number.octal=0755
number.big=12345678901234567890
############################################
# BOOLEANS & NULLS
############################################
boolean.true=true
boolean.false=false
boolean.YES=YES
boolean.no=no
null.lower=null
null.upper=NULL
null.tilde=~ # YAML-style null equivalent
############################################
# DATES & TIMES (YAML-LIKE)
############################################
date.iso=2026-01-27
time.iso=14:30:59
datetime.iso=2026-01-27T14:30:59Z
datetime.offset=2026-01-27T14:30:59+06:00
############################################
# LISTS (SIMULATED)
############################################
list.inline=[apple, banana, cherry]
list.csv=apple,banana,cherry
list.indexed.0=apple
list.indexed.1=banana
list.indexed.2=cherry
############################################
# MAPS / OBJECTS (SIMULATED)
############################################
map.inline={host: localhost, port: 8080}
map.host=localhost
map.port=8080
map.credentials.user=admin
map.credentials.pass=secret
############################################
# MULTILINE VALUES
############################################
multiline.continued=This line continues \
onto the next line \
and another line
multiline.indented=First line \
Indented continuation \
Deep indent
############################################
# SPECIAL CHARACTERS
############################################
special.chars=!@#$%^&*()_+-=[]{}|;:',.<>/?
special.unicode=こんにちは世界 🌍 🚀
special.math=∑ ∆ √ ∞ ≈ ≠ ≤ ≥
############################################
# KEYS EDGE CASES
############################################
.key.starts.with.dot=value
key.ends.with.dot.=value
key-with-dash=value
key_with_underscore=value
key123numbers=value
123numeric.key=value
############################################
# SEPARATORS
############################################
separator.equals=value
separator.colon:value
separator.space value
############################################
# THEME-STRESS CASES
############################################
UPPERCASE.KEY=VALUE
camelCaseKey=camelCaseValue
snake_case_key=snake_case_value
kebab-case-key=kebab-case-value
mixed.SeParAtOr : value with spacesIt still lacks some basic features:
etc I think we can implement it to make it compatible with all cases mentioned in https://en.wikipedia.org/wiki/.properties. |
The documentation is in runtime/syntax/README.md and |
ashikur-rahman-shad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions ❤️
I was in a rush and edited the yaml.yaml file to achieve this. Since it separates the text and the code, it worked well for me. Your changes make it support .properties files perfectly!
This PR adds native support for the
.propertiesformat, a standard for Java, Spring, and infrastructure tools like Apache Kafka.Why this is needed:
Without out-of-the-box support, users often assume Micro is incompatible with their configuration files when they see plain, uncolored text. These files are typically filled with dense comments; without highlighting, it is difficult to distinguish active settings from documentation, leading to configuration errors.
Benefits:
The code
Without
propertiessupport:With
propertiessupport:Temporary workaround:
Run this bash command