Naoray / laravel-goto-components

Quick jump to components
MIT License
13 stars 5 forks source link

associate blade files with html #7

Open lordsteve opened 3 years ago

lordsteve commented 3 years ago

It looks like the extension breaks if you associate blade.php files with HTML in settings. I do this so the markup is color-coded like HTML in the components.

Naoray commented 3 years ago

That’s odd. Can you paste your vexatious vscode settings that is causing the issue?

What do you mean by „breaking“ exactly?

On Sun 5. Dec 2021 at 19:14, Steve Beaudry @.***> wrote:

It looks like the extension breaks if you associate blade.php files with HTML in settings. I do this so the markup is color-coded like HTML in the components.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Naoray/laravel-goto-components/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNPA5GSB3UFGEZZOCAAMCLUPOTXLANCNFSM5JNBMWYQ .

-- Krishan König

Website https://bitmate.dev/ | Github https://github.com/naoray | Twitter https://twitter.com/NaorayKroaths

lordsteve commented 3 years ago

Sure thing, it's right in settings.json

"files.associations": {"*blade.php": "html"}

When it's there, the HTML inside my Blade component is colored to match HTML markup, but I can't click any of the <x-component> tags. When it's not, I can click them, but the HTML is all plain white text.

Naoray commented 3 years ago

Could also paste your folder structure for the resources folder and which component you are referring to.

I m currently not on my laptop so I can’t check, but I also use blade files with the right markup and it works for me

On Sun 5. Dec 2021 at 19:54, Steve Beaudry @.***> wrote:

Sure thing, it's right in settings.json

"files.associations": {"*blade.php": "html"}

When it's there, the HTML inside my Blade component is colored to match HTML markup, but I can't click any of the tags. When it's not, I can click them, but the HTML is all plain white text.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/Naoray/laravel-goto-components/issues/7#issuecomment-986281651, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNPA5GQNKTZGWB3UMZ6Y7LUPOYQHANCNFSM5JNBMWYQ .

-- Krishan König

Website https://bitmate.dev/ | Github https://github.com/naoray | Twitter https://twitter.com/NaorayKroaths

lordsteve commented 3 years ago

So I comment it out

Screen Shot 2021-12-05 at 1 49 48 PM

and it looks like this

Screen Shot 2021-12-05 at 1 50 23 PM

I put it back in

Screen Shot 2021-12-05 at 1 49 33 PM

and it looks like this

Screen Shot 2021-12-05 at 1 49 59 PM

structure looks like this

Screen Shot 2021-12-05 at 2 05 06 PM

And I'm currently looking at resources/views/components/setting.blade.php

Naoray commented 2 years ago

@lordsteve I was able to reproduce the bug, but couldn't figure out why exactly this is happening.

As I said before, I don't have this files.assotiations setting for blade files and my IDE still shows the html code colored properly

image

As a workaround I'd highly recommend installing the following blade highlighting extension. While you are at it, you should also consider using Laravel Blade Formatter extension.

Hope that helps for now. If you want and have the time to look into the cause of this issue I'd highly appreciate it. Otherwise I'd probably sit it here for a bit until more ppl complain.

igorgaming commented 2 years ago

This error is related to this lines: https://github.com/Naoray/laravel-goto-components/blob/976dee31bb1259bcdf356ec8cc99d11c0ce7b83b/src/extension.ts#L8-L10

This is where the Hover and Link provider are registered for blade files. Because in the settings we associate blade files with html, these providers are not registered for them I believe.

But I do not know how to fix it. Most likely, there should be a way to determine the association of the blade file with html in order to register these providers for html files, or even an association of files by extension.

A "quick" solution may be to register providers for both blade and html files, but I think this is a bad solution.

Because these methods take the first parameter DocumentSelector which can be DocumentFilter, we can try to use it and pass an object of the object:

 let hover = languages.registerHoverProvider(['blade', { language: 'html', pattern: '*.blade.php' }], new HoverProvider());

But I do not know if it will work