facelessuser / ApplySyntax

Syntax detector for Sublime Text
https://facelessuser.github.io/ApplySyntax/
343 stars 48 forks source link

Not being able to find a syntax should not only be printed in debug mode #156

Open FichteFoll opened 1 year ago

FichteFoll commented 1 year ago

While trying to figure out why my rule didn't work and eventually setting "debug": true, I noticed the following on the console:

ApplySyntax: Syntax file for Bash does not exist at Packages/Shellscript/Bash.sublime-syntax

In my opinion, this is not the kind of message that should require to enable debug mode to be visible. Note that I'm only using custom rules and none of the defaults, but even then I still believe such a message could be useful to see every once in a while for people who do not have the third-party syntax installed that the default configuration wants to set.

For multiple syntaxes ina rule, this should only report whether each syntax can be found either in debug mode or when none of them could be found.

My rule, for comparison:

        {
            "syntax": "Shellscript/Bash",
            "rules": [
                {"file_path": ".*/\\.env(\\.[^/]*)?$"},
            ]
        },

(must be ShellScript)

facelessuser commented 1 year ago

Yeah, we could consider printing it outside of debug. The idea was that people could enable debug when they were adding and debugging custom commands and then disable debug to turn off noise once they've confirmed their custom rules were working.

The idea is that when you notice a problem, you can enable debug to see what is going on, but I guess we could consider always displaying. I'll evaluate potential annoyances that could occur if we do this. I wonder if default rules, which may not apply to everyone's system, would cause a lot of noise. If so, I may pass on this.

jfcherng commented 1 year ago

Just fyi, for my AutoSetSyntax plugin,

Example Output Panle Msg

``` 🤠 Howdy! This is AutoSetSyntax 2.11.10. (Panel for Window(2)) 🌱 Environment: ST 4150 (windows_x64 dev build) with Python 3.8.12 🔍 Found "Match" implementations: all, any, ratio, some 🔍 Found "Constraint" implementations: contains, contains_regex, first_line_contains, first_line_contains_regex, is_arch, is_extension, is_guesslang_enabled, is_hidden_syntax, is_in_git_repo, is_in_hg_repo, is_in_python_django_project, is_in_ruby_on_rails_project, is_in_svn_repo, is_interpreter, is_line_count, is_name, is_platform, is_platform_arch, is_size, is_syntax, name_contains, name_contains_regex, path_contains, path_contains_regex, relative_exists, selector_matches 📜 Compiled syntax rule collection: SyntaxRuleCollection(version='2.11.10', rules=(SyntaxRule(comment='AutoSetSyntax Debug Information', syntax=Syntax('Packages/Python/Python.sublime-syntax', 'Python', False, 'source.python'), syntaxes_name=('scope:source.python',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='first_line_contains_regex', args=('^# === AutoSetSyntax Debug Information === #',), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/Markdown/Markdown.sublime-syntax', 'Markdown', False, 'text.html.markdown'), syntaxes_name=('scope:text.html.markdown',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('TODO', 'README', 'CHANGELOG'), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/User/my_language/requirements-txt/pip-requirements.sublime-syntax', 'pip requirements', False, 'source.pip-requirements'), syntaxes_name=('scope:source.pip-requirements',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='name_contains_regex', args=('^requirements(-.*)?.txt$',), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/User/my_language/SSH-Config/SSH-Config.sublime-syntax', 'SSH Config', False, 'source.ssh-config'), syntaxes_name=('scope:source.ssh-config',), selector='text.plain | text.xml.config', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='path_contains_regex', args=('/\\.ssh/config$',), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/INI/INI.sublime-syntax', 'INI', False, 'source.ini'), syntaxes_name=('scope:source.ini',), selector='text.plain | text.xml.config', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('^\\[[^\\]]+\\]\\s*$',), kwargs={'threshold': 1}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^[\\w.]+\\s*=',), kwargs={'threshold': 2}, inverted=False))), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^\\[[^\\]]+\\]\\s*$',), kwargs={'threshold': 3}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^[\\w.]+\\s*=',), kwargs={'threshold': 4}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Python/Python.sublime-syntax', 'Python', False, 'source.python'), syntaxes_name=('scope:source.python',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('^(?:def|class)\\s',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^import(?!\\s+groovy)(?:$|[\\s(])', '^from\\s+[a-zA-Z.]+\\s+import(?:$|[\\s(])'), kwargs={}, inverted=False)))), SyntaxRule(comment='Basic INI files', syntax=Syntax('Packages/INI/INI.sublime-syntax', 'INI', False, 'source.ini'), syntaxes_name=('scope:source.ini',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('.minttyrc', '.wslconfig'), kwargs={}, inverted=False),))), SyntaxRule(comment='Basic JSON files', syntax=Syntax('Packages/JSON/JSON.sublime-syntax', 'JSON', False, 'source.json'), syntaxes_name=('scope:source.json',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.css.map', '.geojson', '.js.map', '.jsonc', '.webmanifest'), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='is_name', args=('.babelrc', '.bowerrc', '.csslintrc', '.eslintrc', '.jscsrc', '.jshintrc', '.markdownlintrc', '.stylelintrc'), kwargs={}, inverted=False)))), SyntaxRule(comment='Basic YAML files', syntax=Syntax('Packages/YAML/YAML.sublime-syntax', 'YAML', False, 'source.yaml'), syntaxes_name=('scope:source.yaml',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('.clang-format', '.clang-tidy', '.clangd'), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/ShellScript/Bash.sublime-syntax', 'Bash', False, 'source.shell.bash'), syntaxes_name=('scope:source.shell.bash',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('profile', '.bash_history'), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='name_contains_regex', args=('\\.(?:bash|z(?:shrc|shenv|profile|login|logout))(?:\\.[^/]*)?$',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='first_line_contains_regex', args=('^\\s*#\\s+shellcheck\\s+shell=(?:bash|zsh)',), kwargs={}, inverted=False)))), SyntaxRule(comment='Linux .env files', syntax=Syntax('Packages/ShellScript/Bash.sublime-syntax', 'Bash', False, 'source.shell.bash'), syntaxes_name=('/DotENV.', 'scope:source.shell.bash'), selector='', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='selector_matches', args=('text.plain',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='is_hidden_syntax', args=(), kwargs={}, inverted=False))), MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('.envrc',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='name_contains_regex', args=('\\.(?:env)(?:\\.[^/]*)?$',), kwargs={}, inverted=False)))))), SyntaxRule(comment='', syntax=Syntax('Packages/Git Formats/Git Config.sublime-syntax', 'Git Config', False, 'text.git.config'), syntaxes_name=('scope:text.git.config',), selector='- text.git.config', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='path_contains_regex', args=('/\\.?git/config$',), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/C++/C++.sublime-syntax', 'C++', False, 'source.c++'), syntaxes_name=('scope:source.c++',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('(?:^|\\s)#include\\s*[<"]', '(?:^|\\s)#pragma\\s+(?:once|pack|(?:pop|push)_macro|warning)(?=$|\\s)', '(?:^|\\s)template\\s*<\\s*(?:class|typename)(?=$|\\s)', '\\b(?:const(?:eval|expr|init)|decltype|nullptr|(?:const|dynamic|reinterpret|static)_cast)(?=$|\\s)'), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/C#/C#.sublime-syntax', 'C#', False, 'source.cs'), syntaxes_name=('scope:source.cs',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('^using\\s',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^namespace\\s',), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Diff/Diff.sublime-syntax', 'Diff', False, 'source.diff'), syntaxes_name=('scope:source.diff',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('^\\+{3} ',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^-{3} ',), kwargs={}, inverted=False))), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^@@ -\\d+,\\d+ \\+\\d+,\\d+ @@',), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Go/Go.sublime-syntax', 'Go', False, 'source.go'), syntaxes_name=('scope:source.go',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='contains_regex', args=('^(?:package)\\s',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^(?:import|func|type)\\s',), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/User/my_language/Jenkinsfile.sublime-syntax', 'Jenkinsfile', False, 'source.groovy.jenkinsfile'), syntaxes_name=('Jenkinsfile', 'scope:source.groovy'), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='name_contains_regex', args=('^Jenkinsfile(?=\\b|_)',), kwargs={}, inverted=False),))), SyntaxRule(comment='', syntax=Syntax('Packages/Java/Java.sublime-syntax', 'Java', False, 'source.java'), syntaxes_name=('scope:source.java',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='first_line_contains_regex', args=('^\\s*import\\s+java\\.',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('\\bimport\\s+java\\.', '\\bSystem\\.out\\.println\\s*\\('), kwargs={'threshold': 2}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/JavaScript/JavaScript.sublime-syntax', 'JavaScript', False, 'source.js'), syntaxes_name=('scope:source.js',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_guesslang_enabled', args=(), kwargs={}, inverted=True), ConstraintRule(constraint="", constraint_name='contains_regex', args=('\\bconsole\\.(?:assert|debug|error|info|log|trace|warn)\\s*\\(', '(?:^|\\s)export\\s+default\\s'), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Lua/Lua.sublime-syntax', 'Lua', False, 'source.lua'), syntaxes_name=('scope:source.lua',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_name', args=('.conkyrc',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='is_interpreter', args=('lua',), kwargs={}, inverted=False)))), SyntaxRule(comment='Makefile', syntax=Syntax('Packages/Makefile/Makefile.sublime-syntax', 'Makefile', False, 'source.makefile'), syntaxes_name=('scope:source.makefile',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='name_contains_regex', args=('^Makefile\\.',), kwargs={'regex_flags': ['IGNORECASE']}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^.PHONY\\s*:',), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Matlab/Matlab.sublime-syntax', 'MATLAB', False, 'source.matlab'), syntaxes_name=('scope:source.matlab',), selector='text.plain | source.objc', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.m',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^\\s*%',), kwargs={'threshold': 2}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Objective-C/Objective-C.sublime-syntax', 'Objective-C', False, 'source.objc'), syntaxes_name=('scope:source.objc',), selector='text.plain | source.matlab', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.m',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='contains_regex', args=('^\\s*(?:@(?:interface|class|protocol|property|end|synchronised|selector|implementation)\\b|#import\\s+.+\\.h[">])',), kwargs={}, inverted=False)))), SyntaxRule(comment='"Ruby on Rails" project', syntax=Syntax('Packages/Rails/Ruby (Rails).sublime-syntax', 'Ruby (Rails)', False, 'source.ruby.rails'), syntaxes_name=('scope:source.ruby.rails',), selector='source.ruby', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.rb', '.rake'), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='is_in_ruby_on_rails_project', args=(), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=Syntax('Packages/Ruby/Ruby.sublime-syntax', 'Ruby', False, 'source.ruby'), syntaxes_name=('scope:source.ruby',), selector='text.plain', on_events=None, root_rule=MatchRule(match="", match_name='any', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.simplecov',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='is_name', args=('Cartfile', 'Cartfile.private', 'Cartfile.resolved', 'config.ru', 'Dangerfile'), kwargs={'case_insensitive': True}, inverted=False), ConstraintRule(constraint="", constraint_name='is_interpreter', args=('ruby',), kwargs={}, inverted=False)))), SyntaxRule(comment='', syntax=None, syntaxes_name=('scope:text.html.handlebars',), selector='text.plain | text.html', on_events=None, root_rule=MatchRule(match="", match_name='all', args=(), kwargs={}, rules=(ConstraintRule(constraint="", constraint_name='is_extension', args=('.html',), kwargs={}, inverted=False), ConstraintRule(constraint="", constraint_name='first_line_contains_regex', args=('^