Skip to content

Expand git-config filename pattern to include */git/config#4025

Open
injust wants to merge 2 commits intomicro-editor:masterfrom
injust:patch-1
Open

Expand git-config filename pattern to include */git/config#4025
injust wants to merge 2 commits intomicro-editor:masterfrom
injust:patch-1

Conversation

@injust
Copy link
Contributor

@injust injust commented Feb 26, 2026

micro currently doesn't highlight ~/.config/git/config because the filename pattern requires the directory to be named .git/ (with a dot).

Related to #3962

@injust injust changed the title Expand git-config filename pattern to include foo/git/config Expand git-config filename pattern to include */git/config Feb 26, 2026
Copy link
Member

@JoeKar JoeKar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andriamanitra
Do you see something I didn't?


detect:
filename: "git(config|modules)$|\\.git/config$"
filename: "git(config|modules)$|^(.*[\\/])?\\.?git[\\/]config$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need more backslashes if [\\/] is supposed to match both regular and windows-style path separators...

Suggested change
filename: "git(config|modules)$|^(.*[\\/])?\\.?git[\\/]config$"
filename: "git(config|modules)$|^(.*[\\\\/])?\\.?git[\\\\/]config$"

Copy link
Contributor Author

@injust injust Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In [\\/], I'm not sure if the backslash is treated as an escape character. But what I have now is consistent with the rest of the syntax highlighting files.

But we should really change all these strings to single-quoted strings to avoid all the backslashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In [\\/], I'm not sure if the backslash is treated as an escape character.

In YAML the content of "[\\/]" already results in a interpret string of [\/] used by regexp due to its presence within []. Only the representation of the same string written in Go needs to be "[\\\\/]".
So I'd assume that the current state should work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test it? At least on my machine it wouldn't recognize git\config without the extra backslashes. I'm on Linux so the \ is a part of the filename rather than a path separator but I believe the path matching should work the same regardless of how the OS treats it.

The double-quoted string in yaml eats the first escape so the regex just sees [\/], which it interprets as "character group with a literal / in it" (/ doesn't require escaping but it's still treated as an escape sequence).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, looks you're right. I tried it now too...sorry for that.
This means, that the same check in git-commit.yaml, git-rebase-todo.yaml and ruby.yaml doesn't work either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, looks you're right. I tried it now too...sorry for that. This means, that the same check in git-commit.yaml, git-rebase-todo.yaml and ruby.yaml doesn't work either.

What makes me wonder is that it didn't work the easy (single-escaped) way, when I used single-quotes for the YAML string. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes me wonder is that it didn't work the easy (single-escaped) way, when I used single-quotes for the YAML string. 🤔

[\\/] should work with single-quoted string. Maybe you forgot to change the \\. to \.?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you forgot to change the \\. to \.?

Exactly, this was the case. 👍

But we should really change all these strings to single-quoted strings to avoid all the backslashes.

I agree, this would really help to simplify all of the regex strings...especially the ones where we used \\\\. and all of this double backslash escaping.

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.

4 participants