Skip to content
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

syntax highlighting missing for conf and config files #2179

Open
oscarpax opened this issue Aug 7, 2021 · 7 comments
Open

syntax highlighting missing for conf and config files #2179

oscarpax opened this issue Aug 7, 2021 · 7 comments

Comments

@oscarpax
Copy link

oscarpax commented Aug 7, 2021

Description of the problem or steps to reproduce

Unlike nano, micro seems to be missing syntax highlighting for .conf and config files among other file types. If it wasn't for this, I'd move over from nano in a heartbeat. Thanks.

Specifications

Commit hash: micro 2.0.10-1
OS: Arch Linux
Terminal: kitty, alacritty

@zoomosis
Copy link
Contributor

You can create your own custom syntax highlighting files for Micro. Here's a rough attempt I wrote for .conf files. It's based on the syntax highlighting for Apache config files and so assumes comments begin with #.

Save it to ~/.config/micro/syntax/conf.yaml

filetype: conf

detect:
    filename: "(\\.(conf)$|\\.(cfg)$)"

rules:
    - constant.string:
        start: "\""
        end: "\""
        skip: "\\\\."
        rules:
            - constant.specialChar: "\\\\."

    - comment:
        start: "#"
        end: "$"
        rules:
            - todo: "(TODO|XXX|FIXME):?"

@Calinou
Copy link
Contributor

Calinou commented Aug 12, 2021

Someone could open a pull request to add built-in syntax highlighting for .conf files 🙂

@oscarpax
Copy link
Author

oscarpax commented Aug 12, 2021

@zoomosis Thanks!

@smathles
Copy link

Bump for this issue. Possibly an easy fix to do ourselves, but it would be nice as default!

@kernkraft235
Copy link

kernkraft235 commented May 11, 2024

In general, it would be nice if micro just let me associate filetypes with an existing syntax highlighting. There has never been a time I opened an "unknown" filetype and was glad it was uncolored. The "ini" syntax highlighting is an extremely sane default.

A general space/tab/comma/etc delimited syntax would be a nice addition as well for "wall of text" files like fstab and logs. The rainbow csv vscode extension does this and its so nice for quick readability. When I was a linux noob and barely was able to use CLI to begin with, rainbow mode would have been a blessing, I didn't even know what syntax highlighting was at first. I say this because micro kinda has the de facto title of being the most accessible CLI editor.

I would either:
1. Make "ini" the default, or create a setting for default/fallback syntax
2. Have a quick setting to associate a file extension or just specific file to a syntax file and remember it.
3. Go the extra mile for beginner users and make a dumb-fire/catchall rainbow syntax.

examples that accomplish this:
set filetype.override conf ini
set filetype.default ini

"Rainbow mode" as fallback highlighting

set rainbow [on|off|all]
set rainbow.delimter ' ' OR set rainbow.delimiter ','

@Andriamanitra
Copy link
Contributor

@kernkraft235

Make "ini" the default, or create a setting for default/fallback syntax

Default syntax highlighting was discussed and implemented in #2933 (not in the latest release yet so you need to build from git to get the feature). The default doesn't include .ini syntax but you may provide your own ~/.config/micro/syntax/default.yaml.

Have a quick setting to associate a file extension or just specific file to a syntax file and remember it.

You can achieve this by having the following in your ~/.config/micro/settings.json:

{
    "*.conf": {
        "filetype": "ini"
    },
}

Go the extra mile for beginner users and make a dumb-fire/catchall rainbow syntax.

This is a separate issue (you should probably open a separate issue for discussion if you feel strongly about it) but I think it would be rather tricky to implement with the current regex-based syntax highlighting system.

@neitsab
Copy link
Contributor

neitsab commented Jul 15, 2024

Something I don't understand is that on Debian 11 (current oldstable) with micro v2.0.8, set filetype conf does produce a result (i.e. lines starting with # are greyed out), while on Arch with v2.0.13 it doesn't.

Does it mean micro used to have a definition syntax for conf files that was removed in a later release?

Edit: I found it, it was commit 975e78d which removed the conf syntax highlighting definition (too many conflicts apparently)

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

No branches or pull requests

7 participants