bat icon indicating copy to clipboard operation
bat copied to clipboard

Read from `.sublime-syntax`'s `hidden_file_extensions`

Open 0x326 opened this issue 3 years ago • 3 comments

Would it be possible for bat to read from the hidden_file_extensions property of .sublime-syntax files in addition to the file_extension property? For some projects, file types are have a different extension than usual, such as XML in C# and VB.NET projects (.csproj and .vbproj are written in XML syntax). These less common extensions seem to be already listed in some .sublime-syntax files, but are not currently being read by bat (example).

Expected behavior: Syntax highlighting of files such as .csproj

Current behavior: No syntax highlighting

0x326 avatar Jun 27 '22 12:06 0x326

Support for hidden_file_extensions was added to syntect 5.0.0 (https://github.com/trishume/syntect/pull/419) so this should be pretty straightforward to do. Tentatively setting as good-first-issue.

Enselic avatar Jun 27 '22 18:06 Enselic

@Enselic Could you provide some more details? Which pieces of the code would be involved in this? I'd like to work on my first rust contribution 😺

dufferzafar avatar Aug 05 '22 14:08 dufferzafar

Hmm, after thinking some more about it, I actually expected it to already work. But the syntect implementation looks incomplete. bat relies on the following code, but I think it should be changed to also take hidden_file_extensions into account:

https://github.com/trishume/syntect/blob/606450becf047721b1411da7b1ddd782e6c25d3d/src/parsing/syntax_set.rs#L185-L187

Maybe you can make your first rust contribution towards syntect rather than bat? :angel:

Enselic avatar Aug 14 '22 19:08 Enselic