DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
79 stars 10 forks source link

Blade Syntax Highlighting Problems/Errors #554

Open trollfalgar opened 4 months ago

trollfalgar commented 4 months ago

I will address some syntax highlighting problems

@class() directive:

image

The class colors are mess up.

image

In some cases, @class() is recognized to expect an array, but, after formatting, the code change and is a mess.

Expressions inside parameters

image image

Expressions inside blade component or livewire component parameters should be highlighted in diferente color, now is the same as string. And variables should have intelisense enabled. Exactly like blade directives.

image

But this still lack knowledge of the variables sent to the blade from the controller or the Blade/Livewire component.

Livewire Directives

image

Wthout mention autocomplete for Livewire methods, variables (with types for autocomplete/intelisense), etc (same variables coming from a controller, this would be huge), at least content inside livewire directives should have their own highlighting.

With AlpineJS part of Livewire these days, I beleave some highlighting would be nice

image

@use() directive

image

This directive is relatively new. The extension is not recognizing this. And because of that, we see a warning using the class.

image

User type

When assigning auth()->user() or Auth::user() to a variable with type User we get an warning.

image

jakubmisek commented 4 months ago

@trollfalgar thank you for reporting the problems! I would break them down as follows.

trollfalgar commented 4 months ago

Perfect!

In the case of Laravel: assign auth()->user() /Authenticatable/ to User``: Laravel has a configuration file to specify this. config > auth.php

image

Maybe you can take advantage of this. Can be very flexible if the developer change the default.

jakubmisek commented 4 months ago

The assignment from an interface to the actual class is common practice in PHP. It's not just the Authenticatable :/

jakubmisek commented 4 months ago

If you'd like to try some updates; pre-release 1.46.15414 implements

Preview (completion works best without the quotes): vsc-blade-use-demo

trollfalgar commented 4 months ago

Hello, about @use:

image

When starting to type the namespace, code completion works ok. But only give us parts. We have to type each folder untill we get to the file. Would be possible to give us all the possible namespaces when we start typing?

I personally prefer without quotes, but most people will follow the documentation, and will use quotes. But for a preview, this is nice already.

Obs.: GoTo on click is awesome.

@class() are way better now, but, still strugle after formatting.

BEFORE image AFTER image

jakubmisek commented 4 months ago

Thanks for the fast check!

trollfalgar commented 4 months ago

One more thing!

The variable $attribute inside blade components has a strange behaviour.

Between attributes: image

As the last attribute: image

jakubmisek commented 4 months ago

The variable $attribute inside blade components has a strange behaviour.

Weird it's happening only inside <svg> tag

lyrihkaesa commented 4 months ago

If you'd like to try some updates; pre-release 1.46.15414 implements

  • more syntax highlighting for blade tags inside HTML tags
  • @use directive - fixes false diagnostics and provides code completion for class names
  • @class directive should be recognized correctly

Preview (completion works best without the quotes): vsc-blade-use-demo vsc-blade-use-demo

Please add directive @filamentStyles() and @filamentScripts() in Filament v3: https://filamentphp.com/docs/3.x/notifications/upgrade-guide#new-filamentscripts-and-filamentstyles-blade-directives

image

jakubmisek commented 4 months ago

@lyrihkaesa thank you for the feedback!

We'll add those directives.

The bug itself (that syntax error) is caused by empty parentheses () - will be fixed.

lyrihkaesa commented 4 months ago

@lyrihkaesa thank you for the feedback!

We'll add those directives.

The bug itself (that syntax error) is caused by empty parentheses () - will be fixed.

Oh, it's caused by the empty parentheses () 😢. Thank you very much. 👍 After I tried removing the empty parentheses, it still works fine. I thought there had to be parentheses in the blade directive, but it turns out they are not always necessary, even though the default tab suggestion includes them.

filament

jakubmisek commented 4 months ago

@lyrihkaesa The bug with empty parentheses is fixed in the latest pre-release 1.46.15498. Thanks!