diff --git a/ftplugin/blade.vim b/ftplugin/blade.vim index 8f78ff7..92f876b 100644 --- a/ftplugin/blade.vim +++ b/ftplugin/blade.vim @@ -21,10 +21,11 @@ setlocal comments+=s:{{--,m:\ \ \ \ ,e:--}} if exists('loaded_matchit') && exists('b:match_words') " Append to html matchit words let b:match_words .= ',' . - \ '@\%(section\s*([^\,]*)\|if\|unless\|foreach\|forelse\|for\|while\|push\|can\|cannot\|hasSection\|' . - \ 'php\s*(\@!\|verbatim\|component\|slot\|prepend\)' . + \ '@\%(section\s*([^\,]*)\|if\|unless\|for\|while\|push\|can\|hasSection\|' . + \ 'php\s*(\@!\|verbatim\|component\|slot\|prepend\|once\|hasstack\|fragment\|sectionMissing\|' . + \ 'error\|isset\|empty\s*(\|auth\|guest\|env\|production\|session\|context\|switch\)' . \ ':' . - \ '@\%(else\|elseif\|empty\|break\|continue\|elsecan\|elsecannot\)\>' . + \ '@\%(else\w*\|empty\%(\s*(\)\@!\|break\|continue\|case\|default\)\>' . \ ':' . \ '@\%(end\w\+\|stop\|show\|append\|overwrite\)' . \ ',{:},\[:\],(:)' diff --git a/syntax/blade.vim b/syntax/blade.vim index 3aeb130..504ad4e 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -25,23 +25,33 @@ else setlocal iskeyword+=@-@ endif -syn region bladeEcho matchgroup=bladeDelimiter start="@\@\s*(\@!" end= syn match bladeKeyword "@php\ze\s*(" nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn region bladePhpParenBlock matchgroup=bladeDelimiter start="\s*(" end=")" contains=@bladePhp,bladePhpParenBlock skipwhite contained +syn region bladePhpQuoteBlock matchgroup=bladeDelimiter start='\(\<:[A-Za-z0-9-\.]\+=\)\@50<="' end='"' contains=@bladePhp contained +syn region bladePhpQuoteBlock matchgroup=bladeDelimiter start="\(\<:[A-Za-z0-9-\.]\+=\)\@50<='" end="'" contains=@bladePhp contained syn cluster bladePhp contains=@phpClTop -syn cluster bladeExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,@htmlTop +syn cluster bladeExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,bladePhpQuoteBlock,@htmlTop +syn cluster bladeAttrExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,bladePhpQuoteBlock syn cluster htmlPreproc add=bladeEcho,bladeComment,bladePhpRegion @@ -68,6 +81,12 @@ hi def link bladeComment Comment hi def link bladeTodo Todo hi def link bladeKeyword Statement +hi def link bladeAttr PreProc +hi def link bladeAttrParen bladeAttr +hi def link bladeAttrString bladeAttr +hi def link bladeAttrVar bladeAttr +hi def link bladeAttrEq htmlTag + let b:current_syntax = 'blade' if exists('main_syntax') && main_syntax == 'blade' diff --git a/test.blade.php b/test.blade.php index 76810aa..5abfaac 100644 --- a/test.blade.php +++ b/test.blade.php @@ -1,5 +1,17 @@ @props(['foo' => 'bar', 'baz']) +@aware(['parent' => 'property']) + +@extends('parent.name') +@extendsFirst(["page.$id", "page.default"]) + +@use('App\Models\Example', 'Alias') +@use('App\Models\{Foo, Bar}') +@use(function App\Helpers\format_currency) +@use(const App\Constants\MAX_ATTEMPTS) +@use(function App\Helpers\{format_currency, format_date}) +@use(const App\Constants\{MAX_ATTEMPTS, DEFAULT_TIMEOUT}) + Hello, {{ $name }}. @@ -37,6 +49,8 @@ @forelse ($users as $user)
No users
@endforelse @@ -59,6 +73,12 @@ @endcannot +@canany(['update', 'view'], $post) + +@elsecanany(['create'], \App\Models\Post::class) + +@endcanany +