Closed rzb closed 8 years ago
It works, thanks! I have two options to fix this :
blade-elseif
, but it would be much less intuitive.But since it already isn't working for anyone, I think option 2 is the best.
the solution is really easy, remove the @
from the snippet trigger and change the snippet scope to become text.html.laravel-blade.laravel-blade, text.blade
instead of source.php
and now it will work without any prob + it wont interfere with your php snippets
Somehow, the following snippet is working for me without the "words_separators" trick. I simply type @
and @test
shows up in the tooltip choices. Which is weird, since it wasn't working before... Can any of you two confirm?
<snippet>
<content><![CDATA[
@test('${1:ability}', ${2:\$object})
${3}
@endtest
]]></content>
<tabTrigger>@test</tabTrigger>
<scope>text.html.laravel-blade, text.blade</scope>
<description>Blade @test</description>
</snippet>
I tried it somewhere where the scope was text.html.laravel-blade
, so maybe the scope was the issue initially, not having the @
character in the tabTrigger as we previously thought?
definitely its related to the scope not the trigger, but to be on the safe side you can remove the @
from the trigger to make it easier and more stream lined :)
Trying to make it work here, but it seems that typing @
in a blade template results in absolutely nothing. Was it fixed in the code or is it a solution that I need to apply myself?
It's fixed in v1.2.4. I changed to prefix to Blade::
like in all the other categories.
@Lykegenes If I fire Tool > Snippets, I can see them allright. Although I can't seem to be able to fire the autocomplete for them (and yes, I'm in a .blade.php
file). In regular PHP files, I can still fire snippets just fine though.
(Des releases un weekend? C'est gentil! :P)
@jpmurray Are you typing Blade::if
to fire the snippets? It worked just fine on my work computer when I updated it this morning.
(Je travaille quand je peux! :+1: )
So, as it happens, it I type Blade::if
then it TAB, it will work. I just don't have autocomplete!
I can't really help without more details. I tried on a fresh ST3 install and it works; can you confirm it does on your end too?
Yep, confirmed. I'm on Windows 10, made a fresh install of ST3, and here's what happened : tried in a regular php, blade with @ and with Blade::.
Ha! I think I found the problem! In the bottom right of your screen, you can see that your *.blade.php
file is detected by ST3 as a PHP
file. But the scope of the Blade snippets target Blade files, not PHP files!
There is no syntax for Blade files included by default in ST3; I suggest you install this package, which will provide this functionality for you : Laravel Blade Highlighter.
Then make sure to always open Blade files with the PHP - Laravel Blade
syntax that was installed in the bottom right of your screen.
I cannot specify other packages as dependencies in Package Control, but I'll see what I can do to circumvent this issue.
This semi-adresses it. In my non fresh install, I do already uses Blade Highlighter. With it, I can make the snippets works, but sill no autocomplete :/
Even if it is installed, you're still not using the syntax from the Blade Highlighter package!
You need to click on PHP
in the bottom right of your screen and select PHP - Laravel blade
. Now, you'll have Blade syntax coloring and Blade snippets!
The scope for blade snippets is : text.html.laravel-blade
. I could change it to text.html
so as not to require the Blade Highlighter package, but Blade snippets would show up everywhere there is HTML, even in languages other than PHP; which is not what we want.
I hate to be a downer, but no, even with Blade Highlighter activated, I still get no autocomplete, but yes, the snippet do works without it ;-)
So, I released v1.2.5 which changes the scope of Blade snippets to text.html
so as not to require the Laravel Blade Highlighter
package. I also made another discovery (!) : turns out that the autocomplete only shows up by itself while typing in source code, not in text scopes.
Here's the quick fix; in your Sublime settings there is one named "auto_complete_selector"
, simply add , text.html
at the end. The final result should be :
"auto_complete_selector": "meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc, text.html",
Happy coding!
Yep! auto_complete_selector
did the trick! Merci! ;-)
Not exactly a problem with the snippets, but rather a default configuration in ST3 which threats '@' as a "character that is considered to separate words". This prevents the snippet from triggering until you type the whole tabTrigger parameter, thus making the snippets useless IMO.
To solve it, just add this to your user preferences:
"word_separators": "./()\"'-:,.;<>~!#$%^&*|+=[]{}`~?"