zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.88k stars 1.17k forks source link

Synatx highlighting not working when opening the file the first time! #2031

Closed barmadrid closed 3 years ago

barmadrid commented 3 years ago

This happens with the default theme or with a -tc theme (after I enable True Color) support.

For example, if I try to open fonts.xml or conky.conf I get not syntax highlight. I quit and after the second (or even) third try, I get the expected syntax highlighting!

Version: 2.0.9-dev.39 Commit hash: ba98b558 Compiled on February 16, 2021 OS: Arch Linux Terminal: GNOME terminal 3.38.3

env lists theses:

COLORTERM=truecolor
MICRO_TRUECOLOR=1
zyedidia commented 3 years ago

Is the filetype being detected? It should show the filetype in the status bar at the bottom.

barmadrid commented 3 years ago

@zyedidia I just checked with a fonts.conf file. Sometimes micro says ft:conf (broken syntax) or if I quit and reopen it will detect the same file as ft:xml with working syntax!

The other example is conky.conf is detected as ft:conf (broken syntax) or ft:conky (working syntax).

Apparently the issue is related to .conf extension! (at least in my case).

zyedidia commented 3 years ago

I think the conf syntax highlighting is causing problems in general and isn't very helpful, so I'll just remove it and let the more specific highlighting take its place where possible (conky or xml). In the future this could be solved better by having a priority system in the syntax detection -- I'll think about how this might be designed.

dmaluka commented 3 years ago

One more case of a conflict in syntax detection: *.h header files are highlighted sometimes as C files, sometimes as Objective-C files. I've created issue #2041 for it.