⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@sknaumov
Copy link

@sknaumov sknaumov commented Feb 7, 2026

Proposed changes

Improve syntax highlighting:

Highlight Kconfig output files.

Checklist

  • I have referenced the issue(s) resolved by this PR (if any)
  • I have signed-off my contribution with git commit --amend -s
  • Lint and unit tests pass locally with my changes (make indent && make check)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

I've not tried to build / install mc - I tested my changes on existing installation by modifying /usr/share/mc/syntax/* files.

* Fix broken comments handling.
* Support escapes in basic (double-quoted) strings.
* Highlight literal (single-quoted) strings.
* Support multi-line strings.
* Make tables (sections) easily distinguishable from comments.
* Make highlighting of inline tables consistent.
* Unify colors with other syntax files like YAML / C / Shell.

Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
* Implement Kconfig specification with Kconfiglib extensions.
* Highlight the following files:
  - Kconfig / Kconfig.* - for Linux kernel, U-Boot, Zephyr.
  - Config.in / Config.in.* / Config.src - for Buildroot, Busybox.
  - *.kconf / *.kconfig - just alternative extension-based variant.

Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
* .config is already highlighted as Java properties => reuse it. It is not ideal, but better than nothing.
* Additionally hightlight:
  - .config.* - e.g. .config.old produced by Kconfig.
  - *defconfig - used in Linux kernel, Buildroot, Busybox, U-Boot, Zephyr.
* Kconfig.defconfig should still be treated as Kconfig definition file, not as its output.

Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
@github-actions github-actions bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Feb 7, 2026
@github-actions github-actions bot added this to the Future Releases milestone Feb 7, 2026
@sknaumov
Copy link
Author

sknaumov commented Feb 7, 2026

Please note that I used / for Kconfig.* files not to treat all files in Kconfig directory as Kconfig files.

It looks like Dockerfile file matching rules are incorrect, as all files in Dockerfile* directory will be treated as docker files.

@sknaumov
Copy link
Author

sknaumov commented Feb 8, 2026

BTW, I decided to highlight kconfig output files as Java properties, just because .config - default Kconfig output file, is already highlighted by mc this way, but I'm not sure that it is a right way to go.

.config is quite generic name to treat it exclusively as some Java-related file, and in fact it is an env file in Kconfig case - that could be sourced into any shell script. So probably the right way is to write syntax file for .env files and use it here too instead of relying on some Java-related syntax. Or adjust this syntax to suit both Java properties and env files.

@zyv zyv added area: mcedit mcedit, the built-in text editor and removed needs triage Needs triage by maintainers labels Feb 8, 2026
@zyv
Copy link
Member

zyv commented Feb 8, 2026

Please note that I used / for Kconfig.* files not to treat all files in Kconfig directory as Kconfig files.

It looks like Dockerfile file matching rules are incorrect, as all files in Dockerfile* directory will be treated as docker files.

Actually, there are quite a lot of rules (starting from the very first ones) that assume that we match on the filename and not the full path to the file.

@mc-worker, do you know if there is a reason why we actually match on the full path to the file and does it make sense? Maybe we should change this to really only matching on the file name?

% git diff
diff --git a/src/editor/syntax.c b/src/editor/syntax.c
index 9ccef28ae..8da7173d8 100644
--- a/src/editor/syntax.c
+++ b/src/editor/syntax.c
@@ -1555,7 +1555,7 @@ edit_load_syntax (WEdit *edit, GPtrArray *pnames, const char *type)
 
     f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
     if (edit != NULL)
-        r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
+        r = edit_read_syntax_file (edit, pnames, f, vfs_path_get_last_path_str (edit->filename_vpath),
                                    get_first_editor_line (edit),
                                    auto_syntax ? NULL : edit->syntax_type);
     else

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

Labels

area: mcedit mcedit, the built-in text editor prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

syntax: add highlighting for Kconfig files syntax: multiple issues in syntax highlighting of TOML files

2 participants