Git Product home page Git Product logo

applysyntax's Introduction

Donate via PayPal Discord Build Package Control Downloads License

ApplySyntax

ApplySyntax is a plugin for Sublime Text 2 and 3 that allows you to detect and apply the syntax of files that might not otherwise be detected properly. For example, files with the .rb extension are usually Ruby files, but when they are found in a Rails project, they could be RSpec spec files, Cucumber step files, Ruby on Rails files (controllers, models, etc), or just plain Ruby files. This is actually the problem I was trying to solve when I started working on this plugin.

Credits

DetectSyntax was originally created by phillipkoebbe. In his words, these are his credits:

It all started by forking the plugin created by JeanMertz (1). I modified it quite extensively until I ended up with something entirely my own (2). @maxim and @omarramos commented on the gist and suggested it should be part of Package Control. As I had created it solely for my own consumption, it seemed a bit "hard-coded" to be valuable as a package, but then I took a look at SetSyntax (3). and saw how using settings would make it very flexible. That set me on the path that led to DetectSyntax.

Documentation

https://facelessuser.github.io/ApplySyntax/

License

ApplySyntax is released under the MIT license.

applysyntax's People

Contributors

aaroncrespo avatar alexzhaohong avatar blag avatar bsingr avatar eric-guo avatar exalted avatar facelessuser avatar fnando avatar gabrielecirulli avatar glaucocustodio avatar glenbray avatar hectcastro avatar jonrcahill avatar kangax avatar kes777 avatar kitzberger avatar krinkle avatar krzyzanowskim avatar leek avatar michaelblyons avatar okdana avatar oleg-vinted avatar osxd avatar phillipkoebbe avatar schinkentanz avatar themilkman avatar titobouzout avatar xhacker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applysyntax's Issues

.rb files not getting recognized as rails/rspec

I find ApplySyntax working perfectly well for all non-Ruby related files (yaml,markdown, xml etc.). But for my Rails/Rspec files, ST just defaults to Ruby. Am i missing something in the configuration?

  • I'm using Sublime Text 3 and on the ST3 branch of "ApplySyntax".
  • I did a manual installation (i.e. checked out from the github directly)
  • I have a Packages/User/ApplySyntax.sublime-settings file, but no additional rules in "syntaxes" cause the default_rules from Packages/ApplySyntax/ApplySyntax.sublime-settings should take care of my case.

Would much appreciate the help. Let me know if i need to provide any other information.

oh and thank you @facelessuser for resurrecting DetectSyntax. You my friend are truly a lifesaver.

not working in ST 3?

I installed via package manager and it doesn't seem to be working.

Let me know if this surprises you and I'll get more info.

Syntax from .sublime-package file

Hi!

I'm trying to set the new_file_syntax to Markdown Extended, which is installed as the Markdown Extended.sublime-package file under .config/sublime-text-3/Installed Packages by using

"new_file_syntax": "Markdown Extended/Syntaxes/Markdown Extended",

However, I get

ApplySyntax: Syntax file for Markdown Extended does not exist at Packages/Markdown Extended/Syntaxes/Markdown Extended.tmLanguage

in the console. Should it be possible to load Syntaxes from .sublime-package files?

Should filename used to match file_name expression have path stripped?

I was just trying to setup some files with no extensions as a particular syntax was confused about why it wasn't working.

After some fiddling I realized that the .* on the left-hand side of the default rules isn't just there because it's matching a variable filename, but it's also matching the path.

e.g. my attempt at a rule like this wasn't working:

{"file_name": "myfilename$"}

but this works:

{"file_name": ".*/myfilename$"}

My question is whether anyone would ever want to include path in their match (and if not maybe stripping it ahead of time would make the above more intuitive)? :)

console spam

Hi! I'm seeing a lot of

ApplySyntax: Syntax file for HTML does not exist at Packages/HTML/HTML.sublime-syntax
ApplySyntax: Syntax set to HTML using Packages/HTML/HTML.tmLanguage

Additional syntax rules in user settings file

I believe either custom_syntaxes at root level or (additional|custom)_rules at item level is needed. These new rules wouldn’t necessarily overwrite default rules, but instead get appended to them in order to detect custom file formats/types.

For example, I have some files foo.env and bar.cfg which I would like to auto–detect as “INI” format. In order to do that currently I will have to manually copy all the existing rules to user settings file and add new rules. This is not good, because if default settings file gets updated I won’t have newer rules available unless I figure what was changed.

What do you think?

P.S.: somewhat similar/related to #6

Javascript matching on part of file name

Hey,

I'm trying to use ApplySyntax to match javascript file:

i've app_js.blade.php, but i only match with current *.blade.php.

i've try:

{
    // If you want exceptions reraised so you can see them in the console, change this to true.
    "reraise_exceptions": false,

    // If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
    // The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
    // JavaScript syntax, set new_file_syntax to 'JavaScript'.
    "new_file_syntax": false,

    // Put your custom syntax rules here:
    "syntaxes": [
      {
            // The Cucumber and RSpec rules come before Rails and Ruby because they end in .rb and will be
            // identified as Rails or Ruby otherwise.
            "name": "JavaScript/JavaScript",
            "rules": [
                {"file_name": "*_js\\.blade\\.php$"}
            ]
      }
    ]
}

but it doesn't work... am i doing it wrong?

Thank's!

Improve and complete documentation.

Use mkdocs for documentation. Flesh out all the little rules and such and info that is either undocumented or found in the settings file but not in the readme else.

Add new extension file option for better Sublime integration

Commonly in ApplySyntax, people just want to add a new extension, or a simple wildcard file pattern. For these, a new option is to be added. This new option will create language.sublime-settings files to cause sublime to natively load the correct syntax for a file.

Why do all of this? What is the advantage?

  • Native loaded files will display the correct side bar icon

This is nice, since sidebar icons are based on the syntax a file uses. So ideally, any file that can be expressed with a wild card pattern and written in a sublime-settings file is the better choice for integration

Crash when opening file

From a package-control install, I'm getting tracebacks when opening a file:

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 175, in on_load
  File ".\sublime_plugin.py", line 154, in run_timed_function
  File ".\sublime_plugin.py", line 174, in <lambda>
  File ".\ApplySyntax.py", line 63, in on_load
  File ".\ApplySyntax.py", line 80, in detect_syntax
  File ".\ApplySyntax.py", line 142, in syntax_matches
  File ".\ApplySyntax.py", line 229, in regexp_matches
  File ".\re.py", line 137, in match
  File ".\re.py", line 245, in _compile
sre_constants.error: nothing to repeat

I set my user settings to this for initial testing:

{
    "reraise_exceptions": true,
    "new_file_syntax": false,
    "syntaxes": [
        {
            "name": "Bash",
            "rules": [
                {"file_name": "nginx.conf"}
            ]
        }
    ]
}

Cannot set syntax for vimrc files

I'm trying to set syntax for .vimrc files using VimL plugin, installed via Package Manager, but I failed to do that and really lost.

Could you please help me to debug this?

I have the following rule for the purpose:

{
    "name": "VimL/VimL",
    "rules": [
        {"file_name": "\\.vimrc.*$"}
    ]
}

When I open a PHP file, console log shows: ApplySyntax: Syntax already set to Packages/PHP/PHP.tmLanguage, but when I open a .vimrc file, there's no log message.

Please help.

Thank you.

No such file or directory: 'ApplySyntax/is_rails_file.py'

This error appears when I save my ApplySyntax.sublime-settings:

Writing file /Users/Michael/Library/Application Support/Sublime Text 3/Packages/User/ApplySyntax.sublime-settings with encoding UTF-8 (atomic)
Traceback (most recent call last):
  File "/Applications/Sublime.app/Contents/MacOS/sublime_plugin.py", line 255, in on_post_save
    callback.on_post_save(v)
  File "/Users/Michael/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 66, in on_post_save
    self.detect_syntax(view)
  File "/Users/Michael/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 80, in detect_syntax
    if self.syntax_matches(syntax):
  File "/Users/Michael/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 140, in syntax_matches
    result = self.function_matches(rule)
  File "/Users/Michael/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 201, in function_matches
    function = self.get_function(path_to_file, function_name)
  File "/Users/Michael/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 173, in get_function
    with open(path_to_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'ApplySyntax/is_rails_file.py'
reloading Packages/User/ApplySyntax.sublime-settings

ApplySyntax probably does not work at all for me since there aren't any default language files in the Packages folder:

ApplySyntax: Syntax file for Shell-Unix-Generic does not exist at Packages/ShellScript/Shell-Unix-Generic.tmLanguage

I'm using Package Control and ST3.

Syntax not applied

Syntax setting

{
      "name": "JSON",
      "extensions": ["foo"]
}

When I open a file called some.foo nothing happens, the JSON syntax is not applied

This is what the console says:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 207, in on_load
    callback.on_load(v)
  File "ApplySyntax in ~/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package", line 288, in on_load
  File "ApplySyntax in ~/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package", line 312, in detect_syntax
  File "ApplySyntax in ~/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package", line 392, in syntax_matches
  File "ApplySyntax in ~/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package", line 480, in regexp_matches
  File "./re.py", line 156, in match
  File "./re.py", line 281, in _compile
  File "./sre_compile.py", line 491, in compile
  File "./sre_parse.py", line 747, in parse
  File "./sre_parse.py", line 359, in _parse_sub
  File "./sre_parse.py", line 568, in _parse
sre_constants.error: nothing to repeat

Trying to configure .html files to open as Handlebars when Meteor templates

Meteor apps require .html extensions for their templates, which are really Handlebars templates and should get Handlebars syntax highlighting. Here’s an example. Fortunately, most Meteor templates begin with code like:

<template name="home">

So I would think the following would let me open all Meteor templates using Handlebars syntax highlighting:

                "name": "Handlebars",
                "rules": [
                    {"file_name": ".*\\.html$"},
                    {"first_line": "^<template name="}

But it doesn’t work. See also http://stackoverflow.com/questions/28413968/sublime-setting-default-syntax-for-hbs-html. Any ideas?

ST3 | ApplySyntax does not find syntax file

This is one of my custom rules:

{
    "name": "PHP",
    "rules": [
        {"file_name": ".*\\.(html5)$"}
    ]
}

As soon as I open a *.html5 file, the following error message appears and there is a 50% chance that the correct highlighting will be applied:
ApplySyntax: Syntax file for PHP does not exist at Packages/PHP/PHP.tmLanguage

Applying syntax on very first open

Hi,

Is there a way to apply the syntax on first open of sublime and not just new file creation. I basically want it to always be set to Javascript without having to open new file.

Thanks.

Does not work with Sublime Text 3 (build 3059)

Either I am doing something fundamentally wrong, or this plugin does not work with the lastest stable Sublime Text 3. Neither my custom syntaxes nor the default syntaxes seem to be applied.

For example the INI-Syntax is not applied to Git files, even though I have the corresponding Syntax-Package (clintberry/sublime-text-2-ini) installed.

What might be the issue here?

The only hint I get from Sublime is from the Console:

Unable to open /C/Users/<me>/AppData/Roaming/Sublime Text 3/Packages/ApplySyntax/ApplySyntax.sublime-settings

After updating my rails syntax isn't detected anymore

Something must have changed recently to break how rails syntax was found and set. Any ideas?

ApplySyntax: Syntax file for Ruby on Rails does not exist at Packages/Rails/Ruby on Rails.tmLanguage

No wonder ST3 doesn't keep packages that way anymore. I don't want to have to copy language files to that directory for every syntax I want to support. So how can we fix this?

So I tried installing it from the package manage:

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 207, in on_load
callback.on_load(v)
File "/Users/mhenrixon/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 63, in on_load
self.detect_syntax(view)
File "/Users/mhenrixon/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 80, in detect_syntax
if self.syntax_matches(syntax):
File "/Users/mhenrixon/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 140, in syntax_matches
result = self.function_matches(rule)
File "/Users/mhenrixon/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 201, in function_matches
function = self.get_function(path_to_file, function_name)
File "/Users/mhenrixon/Library/Application Support/Sublime Text 3/Installed Packages/ApplySyntax.sublime-package/ApplySyntax.py", line 173, in get_function
with open(path_to_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'ApplySyntax/is_rails_file.py'

Sublime snippet files as XML in defaults?

For some reason when saved new snippets (i.e., foobar.sublime-snippet) syntax is changed automatically to SCSS, therefore I had to add…

{
    "name": "XML",
    "rules": [
        {"file_name": ".*\\.sublime-snippet$"},
        {"first_line": "^<snippet>$"}
    ]
},

… to my custom rules. Maybe you would want to add this to defaults?

User setting do not apply

Although, I defined user settings the language does not change to Groovy for a file named build.gradle.
Here is my settings file:

{
    "syntaxes": [
        {
            "name": "HTML/HTML",
            "rules": [
                {"file_name": ".*\\.jst.ejs$"},
            ]
        },
        {
            "name": "Groovy/Groovy",
            "rules": [
                {"file_name": ".*\\.gradle$"},
            ]
        },
        {
            "name": "Makefile/Makefile",
            "rules": [
                {"file_name": ".*\\.env$"},
                {"file_name": ".*gitignore$"},
            ]
        },
        {
            "name": "Ruby/Ruby",
            "rules": [
                {"file_name": ".*\\proguard.*(txt|cfg)"},
                {"file_name": ".*Android.mk$"},
                {"file_name": ".*\\.json.rabl$"},
            ]
        },
        {
            "name": "XML/XML",
            "rules": [
                {"file_name": ".*\\.gml$"},
            ]
        },
    ]
}

ApplySyntax doesn't work for me, am i doing it wrong?

i cloned the repo to packages folder (Packages/ApplySyntax), then git checkout to ST3 branch, since i don't need overwrite the default settings, i did'nt create my rules, then restarted sublime, the Vagrantfile is still recognized as plain text .

anyone can help ?

Set JSON syntax highlighting

Hi,

That's not really an issue with ApplySyntax I guess, but I have hard time understanding why it's not working. My user config is:

{
    "syntaxes": [
        {
            "name": "INI",
            "rules": [
                {"file_name": ".*\\.editorconfig$"}
            ]
        },
        {
            "name": "JavaScript/JSON",
            "rules": [
                {"file_name": ".*\\.(csslintrc|jshintrc)$"}
            ]
        }
    ]
}

.editorconfig is now syntax highlighted but not .csslintrc or .jshintrc. How to get JSON syntac highlighting working?

Thanks :)

Using ApplySyntax in ST3/portable

Hey there, I'm struggling to get ApplySyntax to work in a portable installation of ST3 on Windows. I've just cloned the Git repo into ...\st3\Data\Packages\User\ and the plugin itself appears to load: I can see Preferences --> Package Settings --> ApplySyntax entry in the main menu.

I've copied the default config file and jammed the following entry:

    {
        "name": "Makefile",
        "rules": [
            {"file_name": ".*GNUmake.*"}
        ]
    },

Alas, it has no effect. I wonder if it has something to do with the different directory structure of the portable app? Or perhaps with the fact that syntax files are compressed in st3\Packages\ (eg Makefile.sublime-package)

Could you shed some light on this please?

Thanks!

shebang must be described in docs

hi!

recently i'm trying to find some plugin for sublime text to support syntax detection based on shebang (unix file executable detection). i found many modules, but nothing works. after some googling i found DetectSyntax/ApplySyntax. can you explicitly mention shebang support in documentation for this plugin for people like me?

thank you!

INI–type Git files are not correctly detected/applied

Current default settings…

{
    // This rule requires the INI plugin to be installed (via PackageControl or https://github.com/clintberry/sublime-text-2-ini)
    "name": "INI",
    "rules": [
        {"file_name": ".*\\.(gitattributes|gitconfig|gitignore|npmrc)$"},
        {"file_name": ".*\\.ini(\\.dist)?$"}
    ]
},

… will detect/apply [anything].(gitattributes|gitconfig|gitignore) which includes for instance ~/.gitconfig, but Git files can also be in ~/.config/git/ instead (i.e., ~/.gitconfig would be ~/.config/git/config).

This plugin won’t detect them correctly.

MisUnderstanding.

plz excuse the tittle name but i cant find a better word,

essentially what i understood this plugin does is it tells ST to treat any file that have the "?.x" to have the same icon / syntax treatment as the "?.z" ,from the read-me i thought its as easy as you make a "the-name-of-the-ext.sublime-settings" and add the extensions that should follow the same syntax/icon but nothing is happening.
Ex: sass files ,i add this to the setting file

"syntaxes": [
    {
        "name": "Sass/Sass",
        "rules": [
            {"file_name": ".*\\.sass$"},
        ]
    },
]

& made a scss.tmPreferences for the icon ,the string / key cant be written here

scope
    source.sass, source.scss
settings
    icon
       file_type_scss

both sass and scss tmlanguage are installed but nothing has changed :( ,am i missing something ?

Keyword is Deprecated

In my log, I see this: (Please fix ASAP)...

REPRODUCE:

  • i open sublime text 3 [3083] latest,
  • open console, wait for all loading to complete,
  • i have 1 file open a .php file, i hit CTRL+S to Save,
  • i see the following in my console log..
ApplySyntax: Warning: 'file_name' keyword is deprecated and may be removed in the future.
ApplySyntax: Syntax already set to Packages/PHP/PHP.tmLanguage
ApplySyntax: Warning: 'name' keyword is deprecated and may be removed in the future.

So 'file_name' and 'name' got CHANGED or DEPRECATED

Thanks..
💩

Add common dotfiles containing JSON (jshint, csslint, node-jscs)

Configuration files for JSHint, node-jscs and csslint contain JSON, but are formatted as plain text by default in Sublime Text.

I added the following in my User settings which seems to work as expected.

        {
            "name": "JavaScript/JSON",
            "rules": [
                {"file_name": "^.*(\\.jshintrc|\\.jscsrc|\\.csslintrc)$"}
            ]
        }

possible to apply syntax based on file path (rather than filename alone) ?

I thought in the past I had managed to do this using only builtin features of Sublime Text but I can't remember how and googling all points towards your plugin...

I am trying to highlight all *.html files somewhere under a templates/ directory as HTML (Django) syntax (from Djaneiro plugin)

I have this in my User/ApplySyntax.sublime-settings

    "syntaxes": [
        {
            "name": "HTML (Django)",
            "rules": [
                {"file_name": ".*/templates/.+?\\.html?$"}
            ]
        }
    ]

I am pretty sure the regex is correct (it matches a full file path) but the Djaneiro syntax is not being applied... I'm wondering if it's receiving only the file name and not a whole path... and if so is there a rule key I can use for matching against the whole path?

an error

Im seeing the following error on every restart,

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 157, in on_api_ready
m.plugin_loaded()
File "ApplySyntax in C:\Users\luna\AppData\Roaming\Sublime Text 3\Installed Packages\ApplySyntax.sublime-package", line 523, in plugin_loaded
File "ApplySyntax in C:\Users\luna\AppData\Roaming\Sublime Text 3\Installed Packages\ApplySyntax.sublime-package", line 514, in on_reload
File "ApplySyntax in C:\Users\luna\AppData\Roaming\Sublime Text 3\Installed Packages\ApplySyntax.sublime-package", line 203, in update_extenstions
TypeError: can only concatenate list (not "NoneType") to list

My preferences (just in case) looks like this

{
// If you want exceptions reraised so you can see them in the console, change this to true.
"reraise_exceptions": false,

// If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
// The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": "HTML/HTML",
"debug_enabled":false

}

Not work with ST3

Hi.
I try install from Package Control and try manual install by git clone and checkout to ST3 branch but when i open file in rails project ST detect Ruby syntax.

Settings Key Deprecations

  • Deprecate name key and instead use syntax.
  • Deprecate file_name key and instead use file_path.
  • Deprecate binary in favor of interpreter or shebang.

Remember syntax choice

I'm not sure if this belongs here or it may concern more how sublime text work.

Anyway: do you think there is a feasible way to let sublime remember the syntax choice?

I mean if I manually apply a syntax for a file that hasn't an automatic syntax applied and I close/open it again I will still have no syntax highlight applied

Override XML rule

I'm having two problems.

We have a legacy markup for text files that I call "NQ," and for which I wrote a syntax. Every NQ code begins with a $ and has one or two characters following. There are about 40 NQ codes. It looks like this:

$15:$%2333 First Avenue$%Suite 10
$20:$=TBoston

Sometimes NQ files have a .txt extension, so I wrote a rule in ApplySyntax that says if the file begins with $00, apply NQ syntax highlighting.

This worked fine in ST2 but I can't get it to work in ST3.

Sometimes we get files in which the marked-up text is wrapped inside XML elements, like this:

<nq:segment segNo="15">$%2333 First Avenue$%Suite 10</nq:segment>
<nq:segment segNo="20">$TBoston</nq:segment>

In these cases the NQ syntax highlighting should apply to any file that has a .xml extension and which also contains nq:segment.

So I created these syntax rule sets:

{
"name": "NQ/User/NQ",
"match": "all",
"rules": [
  {"file_name": ".*\\.xml$"},
  {"contains": "nq:segment"}
  ]
},
{
"name": "NQ/User/NQ",
"rules": [
  {"first_line": "^\\$00"}
  ]
}

How do I get my first syntax rule set to override the general XML rule that appears first in the default syntaxes? (My XML files do begin with .)

Since I can't get the NQ syntax to apply to either the plain text files containing NQ codes nor to .xml files with nq:segment wrappers, I can't tell if I'm writing the rules wrong or if there's something different about ApplySyntax running in ST3. I'm not yet sure whether ST3 is even seeing the syntax rules.

Btw, I created a /Packages/ApplySyntax folder and put the code there. Apart from /User, it's the only folder in /Packages.

Quick Inquiry

This plugin applies to rules and not really color coding (for example) .ini or .conf files for readability purposes right?

maybe i'm stupid

hi there :)

as far as i understood, applystyntax should allow me to support multiple syntax behaviors on one and the same file. which would be great!

... but i can't manage to get it to work :(

tried to get css3-highlighting to work on both, scss and css files:
"syntaxes": [
{
"name": "Sublime-CSS3/CSS",
"rules": [
{"file_name": "..css$"},
{"file_name": ".
.scss$"},
]
},
]

no chance, don't even get errors...

can u help?

i'm using st3 latest build plus sublime-css3 and scss.
my target is to get css/css3 and sass/scss highlighting running on one file.

regards!

Remove console messages

Hi ! Everytime I open/create a file, the following message in the console appears,

ApplySyntax: Syntax set to HTML using Packages/HTML/HTML.tmLanguage

I would like to have the ability to disable it, I guess in normal usage there is no problem, but when developing packages it mess up with other debug messages, and is not helpful.

Thanks!

ApplySyntax appears to not highlight Guardfiles correctly

Despite the fact there is a default rule in place for Guardfile - using ST3 with ApplySyntax seems to leave Guardfiles interpreted as plain text.

(putting #!/usr/bin/env ruby at the top of the file will work just fine, just thought it should match by default). The relevant section is below:

{
  "name": "Ruby",
  "rules": [
    {"file_name": ".*\\Gemfile$"},
    {"file_name": ".*\\Capfile$"},
    {"file_name": ".*\\Guardfile$"},

ApplySyntax default syntax list is way too much

Browsing through large amount project files using the Ctrl+P method basically becomes usable. Consider commenting out all of the default syntaxes by default and have user enable them individually.

DEPRECATED message showing

This is not a bug, but a feature to help people understand how to setup syntax files etc.

I have been getting tired of answering the same question in regards to setting up syntax file rules. So I have removed alternate formats for setting up function calls and syntax files to make it easier on everyone. They are all done the same way and are consistent now. There should be no more reasons to file issues that are based on users not understanding how to set up calling the syntax file. I am hoping it will now be straight forward.

Example 1:
Packages/Rails/Language/Ruby Haml.tmLanguage
You would define the syntax to be Rails/Language/Ruby Haml

Example 2:
Packages/XML/XML.tmLanguage
You would define the syntax to be XML/XML

Special function rules:
Example 3:
Packages/ApplySyntax/is_rails_file.py (with function name is_rails_file)
{"function": {"name": "is_rails_file", "source": "ApplySyntax/is_rails_file"}}

There are no other formats, only these.

ApplySyntax does not take into account of the Syntaxes folder for certain languages.

For certain languages like JQuery and Jasmine, the tmLanguage file exists in a sub-directory called Syntaxes, in this case, the ApplySyntax would not have work.

Consider adding the following to line 108 of the ApplySyntax.py:
file_name = name + '.tmLanguage'
file_path = os.path.join(sublime.packages_path(), path, file_name)

    # Check for exsistence of the Syntaxes sub-directory for certain languages.
    if not os.path.exists(file_path):
        file_path = os.path.join(sublime.packages_path(), path, 'Syntaxes', file_name)
        new_syntax = sublime_format_path(os.path.join("Packages", path, 'Syntaxes', file_name))
    else:
        new_syntax = sublime_format_path(os.path.join("Packages", path, file_name))

    current_syntax = self.view.settings().get('syntax')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.