Improve syntax detection by acuteenvy · Pull Request #2524 · gitui-org/gitui

Currently, gitui prioritizes file extensions for syntax detection. When a file lacks an extension (e.g. Makefile), or the extension isn't tied to a specific format (e.g. .lock), it disables syntax highlighting.

This PR changes the syntax detecton method to the entire filename and the first line of the file using find_syntax_for_file().

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

Screenshots of highlighting Cargo.lock and Makefile from this repository:

Before

old1
old2

After

new1
new2

Details