-
Notifications
You must be signed in to change notification settings - Fork 40
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
Do not apply syntax highlight to files without extensions #1353
Comments
I like this behavior, so a new setting to turn it on and off is good. |
This doesn't only affect saving files, it also affects opening files with no extension. There was a short discussion about this on the Default Packages repo which arose from some confusion about the |
A number of the default packages use this functionality, especially Ruby |
I think it would be better to use a separate key in the sublime-syntax YAML for it, instead of |
I think it would be useful, if/when this gets implemented, if specific filename matching occurred before file extension matching, so that sublimehq/Packages#611 would be possible. |
Making a change such as this would be kind of a big backwards compatibility break. |
It would be possible to keep the current behavior in |
Another way would be to use the new behavior if the second key exists. I'm still in favor of separating the two though, despite backwards incompatibility. Cluttering the "save as" window with loads of filenames that happen to use this syntax is kinda bad. However, after the change files still need to be able to be saved with these specific names. |
I have a related issue with both ST4 and SM2 where a Python script with filename @jfcherng came with this great work around for ST on Discord's #support : import sublime
import sublime_plugin
class PreferShebangSyntax(sublime_plugin.EventListener):
def on_load(self, view: sublime.View) -> None:
first_line = view.substr(sublime.Region(0, 80))
if first_line.startswith("#!/"):
current_syntax = view.syntax()
target_syntax = sublime.find_syntax_for_file("", first_line)
if target_syntax.path != current_syntax.path and target_syntax.name != "Plain Text":
view.assign_syntax(target_syntax.path) While it's not exactly what is asked here, this seems like the expected behavior for such cases. |
By the way, I have that as a part of functionalities in https://packagecontrol.io/packages/AutoSetSyntax. |
I like the behavior by matching end of file. It is required to highlight Probably syntax highlighter should be just configured as Thus we should not implement new keys, we just need to reconfigure those modules so they will setup |
That potentially breaks plugins. But even with a new key, removing |
Summary
When save files with names such as: 'r', 'pl' syntax is changed
Expected behavior
Syntax is not changed
Steps to reproduce
Environment
The text was updated successfully, but these errors were encountered: