Skip to content

Commit 743fbe2

Browse files
azizkprincemaple
authored andcommitted
Commands: fixed syntax detection for enabling/disabling commands. (#58)
Use scope suffixes instead of syntax file names.
1 parent 3ed6e7f commit 743fbe2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

commands/utils.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ def expand_scope_right(view, begin_point, scope):
2121
)
2222
return sublime.Region(begin_point, end_point)
2323

24-
def is_one_of_syntaxes(view, syntaxes):
25-
view_syntax_path = view.settings().get('syntax')
26-
return any(basename + '.sublime-syntax' in view_syntax_path for basename in syntaxes)
24+
def has_one_of_scope_suffixes(view, scope_suffixes):
25+
view_scope_suffixes = view.scope_name(0).split(' ')[0].split('.')[1:]
26+
return any(suffix in view_scope_suffixes for suffix in scope_suffixes)
2727

2828
def is_elixir_syntax(view):
29-
return is_one_of_syntaxes(view, ['Elixir'])
29+
return has_one_of_scope_suffixes(view, ['elixir'])
3030

3131
def is_formattable_syntax(view):
32-
syntaxes = ['Elixir', 'EEx', 'Elixir (EEx)', 'HTML (EEx)', 'HTML (HEEx)', 'HTML (Surface)']
33-
return is_one_of_syntaxes(view, syntaxes)
32+
return has_one_of_scope_suffixes(view, ['elixir', 'eex', 'heex', 'surface'])
3433

3534
def reverse_find_root_folder(bottom_path):
3635
bottom_path = Path(bottom_path)

0 commit comments

Comments
 (0)