Skip to content

Conversation

@ashikur-rahman-shad
Copy link

@ashikur-rahman-shad ashikur-rahman-shad commented Jan 26, 2026

This PR adds native support for the .properties format, 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:

  • Visual Clarity: Clearly separates keys, values, and comments.
  • User Retention: Provides a "works-out-of-the-box" experience for developers.
  • Tested: Verified for accuracy using production-grade Kafka configurations.

The code

filetype: properties

detect:
    filename: "\\.properties$"

rules:
    # Key (Identifier) - Matches everything before the first = or :
    - identifier: "^[[:space:]]*[^=:[:space:]]+"

    # Assignment operators
    - statement: "[=:]"

    # Boolean constants
    - constant.bool.true: "\\b(true|TRUE|yes|ON)\\b"
    - constant.bool.false: "\\b(false|FALSE|no|OFF)\\b"

    # Strings/Values (Simple match for text after assignment)
    - constant.string: "([=:][[:space:]]*).*$"

    # Comments - Properties files support both # and !
    - comment:
        start: "[#!]"
        end: "$"
        rules:
            - todo: "(TODO|XXX|FIXME):?"

    # Special characters like escaped spaces or newlines
    - constant.specialChar: "\\\\([ :=tnfr'\"\\\\]|u[0-9a-fA-F]{4})"

Without properties support:

image

With properties support:

image

Temporary workaround:

Run this bash command

mkdir -p ~/.config/micro/syntax && cat <<'EOF' > ~/.config/micro/syntax/properties.yaml
filetype: properties

detect:
    filename: "\\.properties$"

rules:
    # Key (Identifier) - Matches everything before the first = or :
    - identifier: "^[[:space:]]*[^=:[:space:]]+"

    # Assignment operators
    - statement: "[=:]"

    # Boolean constants
    - constant.bool.true: "\\b(true|TRUE|yes|ON)\\b"
    - constant.bool.false: "\\b(false|FALSE|no|OFF)\\b"

    # Strings/Values (Simple match for text after assignment)
    - constant.string: "([=:][[:space:]]*).*$"

    # Comments - Properties files support both # and !
    - comment:
        start: "[#!]"
        end: "$"
        rules:
            - todo: "(TODO|XXX|FIXME):?"

    # Special characters like escaped spaces or newlines
    - constant.specialChar: "\\\\([ :=tnfr'\"\\\\]|u[0-9a-fA-F]{4})"
EOF

Copy link
Contributor

@Andriamanitra Andriamanitra left a 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>
@ashikur-rahman-shad
Copy link
Author

@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 spaces

It still lacks some basic features:

  1. No multiline string support
  2. Highlights colon, equal, etc in string
  3. Doesn't support space just like colon and equal
key=pair ✅ 
key:pair ✅
key pair 

etc

I think we can implement it to make it compatible with all cases mentioned in https://en.wikipedia.org/wiki/.properties.
Could you also suggest me some resources from where I can learn to edit syntax yaml file for micro? AI is making lots of mistakes.

@Andriamanitra
Copy link
Contributor

Could you also suggest me some resources from where I can learn to edit syntax yaml file for micro?

The documentation is in runtime/syntax/README.md and help colors. Unfortunately some of the details and more advanced features of the system remain undocumented. Reading the existing syntax files and discussions in previous issues and pull requests related to syntax highlighting may help bridge some of those gaps.

Copy link
Author

@ashikur-rahman-shad ashikur-rahman-shad left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants