diff --git a/README.md b/README.md index 9ba4583..83b81f9 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,11 @@ An object specifying a configuration to use when another syntax embeds the `sour If true, JS Custom will automatically rebuild your syntaxes when you modify your user settings. Only syntaxes whose configurations have changed will be rebuilt. If `auto_build` is disabled, you will have to run the rebuild command manually. -### `jsx_close_tag`: boolean +### `jsx_close_tag`: string or boolean -If true, when you run the `close_tag` command in a JavaScript file, this package's `jsx_close_tag` command will be invoked instead. +When you run the `close_tag` command, if the scope of the file matches this selector, then this package's `jsx_close_tag` command will be invoked instead. You may have to modify this setting if you use the `scope` configuration option + +If false, `jsx_close_tag` will never be run. ### `reassign_when_deleting`: string or `false` diff --git a/src/listeners/jsx_close_tag.py b/src/listeners/jsx_close_tag.py index d7e0145..23fd529 100644 --- a/src/listeners/jsx_close_tag.py +++ b/src/listeners/jsx_close_tag.py @@ -8,9 +8,15 @@ class JsxCloseTagListener(sublime_plugin.ViewEventListener): def on_text_command(self, command_name, args): - if ( - command_name == 'close_tag' - and get_settings()['jsx_close_tag'] - and self.view.match_selector(0, 'source.js') - ): + if command_name != 'close_tag': + return + + selector = get_settings()['jsx_close_tag'] + + if not selector: + return + elif selector is True: + selector = 'source.js, source.ts, source.tsx' + + if self.view.match_selector(0, selector): return ('jsx_close_tag', args) diff --git a/sublime/JS Custom - Comments.tmPreferences b/sublime/JS Custom - Comments.tmPreferences new file mode 100644 index 0000000..64128c4 --- /dev/null +++ b/sublime/JS Custom - Comments.tmPreferences @@ -0,0 +1,33 @@ + + + + name + Comments + scope + source.js, source.ts, source.tsx + settings + + shellVariables + + + name + TM_COMMENT_START + value + // + + + name + TM_COMMENT_START_2 + value + /* + + + name + TM_COMMENT_END_2 + value + */ + + + + + diff --git a/sublime/JS Custom - JSX Comments.tmPreferences b/sublime/JS Custom - JSX Comments.tmPreferences index 1e5b06e..143e214 100644 --- a/sublime/JS Custom - JSX Comments.tmPreferences +++ b/sublime/JS Custom - JSX Comments.tmPreferences @@ -5,7 +5,7 @@ name JS Custom - JSX Comments scope - source.js meta.jsx - source.js.embedded.jsx + source.js meta.jsx - source.js.embedded.jsx, source.ts meta.jsx - source.ts.embedded.jsx, source.tsx meta.jsx - source.tsx.embedded.jsx settings shellVariables diff --git a/sublime/JS Custom.sublime-settings b/sublime/JS Custom.sublime-settings index dd08a40..b0df249 100644 --- a/sublime/JS Custom.sublime-settings +++ b/sublime/JS Custom.sublime-settings @@ -37,6 +37,6 @@ }, "auto_build": true, - "jsx_close_tag": true, + "jsx_close_tag": "source.js, source.ts, source.tsx", "reassign_when_deleting": "scope:source.js", }