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)
  • {{ $user->name }}
  • + @break ($user->last) + @continue ($user->skip) @empty

    No users

    @endforelse @@ -59,6 +73,12 @@ @endcannot +@canany(['update', 'view'], $post) + +@elsecanany(['create'], \App\Models\Post::class) + +@endcanany +
    @include('shared.errors')
    @@ -80,9 +100,29 @@ @inject('metrics', 'App\Services\MetricsService') -@push('scripts') +@once + @push('scripts') + + @endpush +@endonce + +@pushOnce('scripts') -@endpush +@endPushOnce + +@pushIf($shouldPush, 'scripts') + +@elsePushIf($pushOther, 'scripts') + +@elsePush + +@endPushIf + +@hasstack('list') + +@endif @@ -95,6 +135,9 @@ @stack('scripts') + + @viteReactRefresh + @vite('resources/js/app.jsx') @prepend('scripts') @@ -102,6 +145,14 @@ @endprepend +@prependOnce('scripts') + +@endPrependOnce + +@fragment('list') + +@endfragment +
    @section('sidebar') This is the master sidebar. @@ -113,11 +164,49 @@ @section('title', 'Page Title') @section('sidebar') - @parent + @@parent

    This is appended to the master sidebar.

    @endsection - +@sectionMissing('navigation') + default navigation +@endif + + + @method('PUT') + @csrf + + + + + @error('terms') +
    {{ $message }}
    + @enderror + + isNotAdmin()) + @required($user->isAdmin()) + aria-disabled="@bool($disable)" + /> + + + +@endcontext + @switch($i) @case(1) case code @break + + @default + default case + @endswitch -@includeFirst + $isActive, + 'big' => $size > 4, // html tag should not end yet + ]) + @style([ + 'margin: 0', + 'font-weight: bold' => $isActive, + ]) +>Link + +@includeIf('view.name') +@includeWhen($condition, 'view.name') +@includeUnless($condition, 'view.name') +@includeFirst(['custom.name', 'name']) + + + + +{{-- double colon prefix not treated as php --}} + + +@dd($foo) +@dump($foo)