-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add a dedicated Path => Syntax lookup database #592
Comments
re the footnote, it may be worth subscribing to this issue in case the situation will improve in future: sublimehq/sublime_text#1353 |
Thank you for the reference! |
I love this idea and just today I was dreaming of a nicely highlighted |
I might be able to attempt a PR if you give me some direction. I'm an experienced engineer, though this would be my first stab at rust... It's ok to say no. I've been an open source maintainer too :) |
Sounds great! All contribution are very welcome. I am happy to give directions / guidance, but probably not this week :-/. |
This could also solve problems like #685 if we could add blacklist-entries of the form:
not sure how to best integrate this with the ideas above. |
I also want to help, hoping to scrath the particular itch that a file named
Hmm, while I could add specifically Now most of these files are upstream syntax definitions from Sublime, no? |
I don't think it can, no. For this particular example, I'm also not sure if we would want to add a rule like this. What about a file called
Yes, most of them are.
No, we would not be able to contribute these changes upstream 🙁, but that's the idea, yes. Happy for any kind of feedback. |
I made a first small step in this direction by implementing a (not yet comprehensive) test suite for syntax detection: #861 |
This has now been implemented (in a slightly more powerful way, using glob patterns) in #877 |
This has been released in bat 0.13. |
Sublime text syntax definitions provide two different ways to "detect" specific languages:
file_extensions
field in the header of the syntax. This allows us (for example) to choose the "C++" syntax for all files with acpp
file extension. It also allows us to choose the "Makefile" syntax for all files calledMakefile
¹.first_line_match
field in the header of the syntax. This allows us (for example) to choose the "Python" syntax for files that start with#!/usr/bin/env python
- even without a.py
extension.It would be great if we could extend our "syntax detection" by allowing bat to choose a specific syntax for certain file path patterns. For example, it would be great if we could automatically use the "SSH Config" syntax for the file
$HOME/.ssh/config
(see #582). Or a (hypothetic) "X11 Config" syntax for all/etc/X11/xorg.conf.d/*.conf
files. Or the "Shell" syntax for/etc/profile
.These examples would be rather hard to match with one of the above techniques as (1) the have very generic names and (2) they don't have a specific "first line pattern".
Before someone goes ahead and implements this, we should probably discuss both the general idea and the implementation details.
In any case, I'd be very glad to get some feedback on this idea.
¹ The☹️
file_extensions
lookup does not actually distinguish between file-extension patterns and full-filename patterns. This means that a file calledcpp
will match the "C++" syntax and a file calledfoo.Makefile
will match the "Makefile" syntaxThe text was updated successfully, but these errors were encountered: