A first party treesitter parser for laravel blade #45286
-
Hey, I haven't seen anyone work on this yet so I figured I'd ask the community / the laravel team whether it's viable and whether anyone else has the issue I'm having. Developers use a lot of different ways to write their laravel code, whether that's emacs, sublime text, vim, neovim, phpstorm and I suppose notepad++. Some of the aforementioned names have great laravel blade support but are behind a paywall which not everyone can afford, or they choose to ignore those options since they're a vim / emacs for life kind of person. Wouldn't it be great if every editor had great support for laravel blade, by utilizing treesitter? What's treesitter? Well.
TL;DR, proper highlighting in blade.php files for everyone. No matter their choice of editor. Here's my problem, I find it rather difficult to do it myself and I'm going to need some help with this. I've tried and failed many times but maybe someone in the community, or someone in the laravel team can work on this. It would greatly improve the developer experience of everyone if Laravel itself could point to an official treesitter parser that takes the pain out of highlighting in blade.php files without pointing to expensive options like phpstorm. Note, if you've solved this issue without treesitter be sure to let everyone know in the comments. I figured I'd ask the community since I still think that an official treesitter parser would be awesome for everyone. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 28 replies
-
I've been in touch with you two before on other matters and I would love your input on this, maybe your large following can give it some more attention if you think it deserves that. |
Beta Was this translation helpful? Give feedback.
-
I have started work on an tree-sitter-blade parser. For now it's experimental. You can find it here: https://github.com/KaranAhlawat/tree-sitter-blade. The commit history may be a bit confusing, sorry about that. |
Beta Was this translation helpful? Give feedback.
-
There seems to be a repository that is actively developing a parser for |
Beta Was this translation helpful? Give feedback.
-
Hello everybody and @unansweredocd I have been working on a grammar for a couple of months now, happy to announce that it is now public 🎉 . you can find it here EmranMR/tree-sitter-blade on github. I would really appreciate if everyone can have a look and provide feedback. It is pretty much complete and up to date as of Laravel 10.x. I use Nova and it worked great there when I was running the tests(unpublished syntax extension). However I recognise tree-sitter-blade would be predominantly used in NeoVim and I have zero experience with that editor, or who knows maybe github as well! So It would be great to have your inputs/feedbacks esp @jessarcher. I wrote it in a way so it is easy to extend the grammar as Laravel grows. This is beta, and have the following features:
Future plans:
Happy Coding |
Beta Was this translation helpful? Give feedback.
-
Splitting the php parser into html/standalone is exactly what is needed. Even the old RegEx based syntax grammars had a separate php and base-php. So hopefully that comes to life sometimes soon... 🤞 Thanks for explaining the |
Beta Was this translation helpful? Give feedback.
-
is their any blade formatter for nvim?? |
Beta Was this translation helpful? Give feedback.
Hello everybody and @unansweredocd I have been working on a grammar for a couple of months now, happy to announce that it is now public 🎉 . you can find it here EmranMR/tree-sitter-blade on github.
I would really appreciate if everyone can have a look and provide feedback. It is pretty much complete and up to date as of Laravel 10.x. I use Nova and it worked great there when I was running the tests(unpublished syntax extension). However I recognise tree-sitter-blade would be predominantly used in NeoVim and I have zero experience with that editor, or who knows maybe github as well! So It would be great to have your inputs/feedbacks esp @jessarcher.
I wrote it in a way so it is easy to ext…