facelessuser / ApplySyntax

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

Unable to auto apply ansible #110

Closed jacobamey closed 7 years ago

jacobamey commented 7 years ago

Probably just me, but i feel like I'm doing this correctly. I do have Ansible syntax installed and can manually set it each time i load a file. No matter what i try though it will not autoset and instead becomes yaml vs ansible highlighting.

        {
        // Ansible Auto Recognition
        "syntax": "Ansible/Ansible",
        "rules": [
            {"file_path": "/home/jamey/Scripting/Ansible/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/app-install/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/os-build/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/sec-work/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/sys-admin/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/tasks/*.yml$"},
            {"file_path": "/home/jamey/Scripting/Ansible/handler/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/vars/*.yml"},
            {"file_path": "/home/jamey/Scripting/Ansible/roles/*.yml"},
            {"file_path": ".*/.*ansible.*/*.yml$"},
            {"file_path": ".*\\\\ansible(\\\\..*)?$"},
        ]
    },
facelessuser commented 7 years ago

There is so much I'll need to know to help. I need a step by step to reproduce (what you did). And link me to a full version of your settings file as I need to confirm it is set up and formatted correctly.

jacobamey commented 7 years ago

Oh yeah no problem. For the most part I followed this blog to get started. https://www.blue-bag.com/blog/ansible-sublime-text I normally just work out of gedit but decided to try out Sublime since its feature rich and light. But anyway, I'm working out of Fedora 25. I installed sublime3, package control, Ansible package, then ApplySyntax. from there i actually did not change anything in the default. I only added ansible syntax to the user settings file. I was unable to find a good example so built it out comparing it to the yaml and python syntax in the default file I also read about file_path in your documentation. ApplySyntax-default.txt ApplySyntax-user.txt

facelessuser commented 7 years ago

Can you also give me an idea of were you physically put your Ansible file and what you name it during your test? I'll need to check what you are testing for in the settings against what you are actually physically testing.

Once I get the test of the info, I'll take a look later today and let you know what I find.

jacobamey commented 7 years ago

Yes my main tests as well are living in /home/jamey/Scripting/Ansible/

a good test since its a file I'm working on right now is.

/home/jamey/Scripting/Ansible/tasks/nginx-install.yml

Thank you for the assistance.

facelessuser commented 7 years ago

Didn't test all your cases, just /home/jamey/Scripting/Ansible/tasks/nginx-install.yml. Anyways, the problem is you weren't using regex syntax in a lot of places. I only took a look at the /home cases. You had things like /* which would look for ////////////// etc. But what you really wanted was /.* where dot means any char. And you had .yml when it should have been \.yml so that dot was a literal dot. Anyways, in short, check your syntax 😉 .

        {
            // Ansible Auto Recognition
            "syntax": "Ansible/Ansible",
            "rules": [
                {"first_line": "^<\\---"},
                {"file_path": "/home/jamey/Scripting/Ansible/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/app-install/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/os-build/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/sec-work/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/sys-admin/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/tasks/.*\\.yml$"},
                {"file_path": "/home/jamey/Scripting/Ansible/handler/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/vars/.*\\.yml"},
                {"file_path": "/home/jamey/Scripting/Ansible/roles/.*\\.yml"},
                {"file_path": ".*/.*ansible.*/*.yml$"},
                {"file_path": ".*\\\\ansible(\\\\..*)?$"}
            ]
        }
jacobamey commented 7 years ago

Ha I knew it was all on my end, regex is something I need to work on for sure. Anyway thanks for fixing my issue.