Skip to content

Commit

Permalink
Added scope extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Smith authored and Thomas Smith committed May 28, 2018
1 parent 271735c commit 2819361
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ These options don't affect the syntax highlighting itself, but rather the way th

The name of the syntax as it will appear in the syntax selector. (If this is omitted, the syntax will be named “JS Custom - <var>name</var>”, where <var>name</var> is the key in the `configurations` object.)

#### `scope`: string

The top-level scope that will be used for the syntax. (If this is omitted, the scope will be “source.js.<var>name</var>”, where <var>name</var> is based on the key in the `configurations` object.)

#### `file_extensions`: array

An array of file extensions. Files with the given extensions will be use this syntax.
Expand Down
5 changes: 4 additions & 1 deletion build_js_custom_syntaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import os
from os import path
import re

from package_control import events
from sublime_lib.output_panel import OutputPanel

SOURCE_PATH = 'Packages/JSCustom/src/JS Custom.sublime-syntax.yaml-macros'

Expand Down Expand Up @@ -92,10 +94,10 @@ def auto_build():
class BuildJsCustomSyntaxesCommand(sublime_plugin.WindowCommand):
def run(self, versions=None):
from yamlmacros import build
from yamlmacros.src.output_panel import OutputPanel
from yamlmacros.src.error_highlighter import ErrorHighlighter

panel = OutputPanel(self.window, 'YAMLMacros')
panel.show()
error_highlighter = ErrorHighlighter(self.window, 'YAMLMacros')

source_text = sublime.load_resource('Packages/JSCustom/src/JS Custom.sublime-syntax.yaml-macros')
Expand Down Expand Up @@ -123,6 +125,7 @@ def run(self, versions=None):
destination_path=path.join(SYNTAXES_PATH, name + '.sublime-syntax'),
arguments=merge({
'name': 'JS Custom - %s' % name,
'scope': 'source.js.%s' % re.sub(r'[^\w-]', '', name.lower()),
'file_path': SOURCE_PATH,
}, configurations[name]),
error_stream=panel,
Expand Down
5 changes: 3 additions & 2 deletions dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"*": {
"*": [
"ruamel-yaml",
"yaml_macros_engine"
"yaml_macros_engine",
"sublime_lib"
]
}
}
}
5 changes: 5 additions & 0 deletions extensions/scope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%YAML 1.2
%TAG ! tag:yaml-macros:yamlmacros.lib.extend,yamlmacros.lib.arguments:
---
!merge
scope: !argument scope
1 change: 1 addition & 0 deletions sublime/JS Custom.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

"embed_configuration": {
"name": "JS Custom (Embedded)",
"scope": "source.js",
"hidden": true,
"file_extensions": [],
"custom_template_tags": false,
Expand Down

0 comments on commit 2819361

Please sign in to comment.