Open gmnz opened 1 week ago
Hi @gmnz, the locations are Laravel one's app/View/Components
and resources/views/components
as Laravel docs states
OK, so if my Laravel app is using components stored inside resources/views/other_than_components_dir, then there's no way to make "gf" work for these components? It works only for components stored in resources/views/components and its subdirs?
Since I’m not aware how Laravel can handle your components in non standard location, nor have any case on my own, yes the standard ones locations. PR are welcome
I searched through the project's code and consulted it with my colleague and the method to make Laravel work with custom view paths that's used in this case is this one:
https://stackoverflow.com/questions/27458439/how-to-set-view-file-path-in-laravel -> accepted answer -> Method 3
Any hints where to start if I wanted to add support for this? If it's not too complicated I may try.
How are you setting the view file path?
I'm not really sure what you're asking for. Is this it?
View::addLocation(resource_path('views/common'));
It's used inside app/Http/Controllers/Controller.php -> __construct
Yes, I'll take a look at it
This also happens to me. I have the components placed in resources/views/components
but still doesn't work.
But here's the catch: the gf
works when the component that I want to navigate is the first one that I open before the file that uses it:
https://github.com/user-attachments/assets/5f00d7bd-5691-4037-892e-bcecbcf6cbff
Hi @datsudo, thank for sharing. Is not the same issue, @gmnz has a custom view location.
Can yo load the view and wait a bit and then gf
to see if happens
Just here to say I would love to see support added for jumping to associated blade files in custom view directories if possible (i.e. ./views instead of ./resources/views). However, the standard paths seem to be hardcoded into much of the codebase, so that might be a big undertaking.
@gmnz and @tylerdak, the way I'll go is to make a Artisan command to obtain the view paths and use them instead of the hardcoded's one via config flag.
As soon as a free time window appears will work on it.
The Artisan command is not the way to go, as you can add locations dynamically that won't be available when the command is executed.
$finder = View::getFinder();
$locations = $finder->getPaths();
dd($locations);
May be enabling exrc
and in a local file you can set the paths to be searched by blade-nav. Something like .nvim.lua
:
vim.g.blade_nav = {
components_paths = {
"resources/views/components".
"resources/views/common".
}
}
Ah yeah Artisan caveat makes sense.
Is there a simpler route for specifying paths, though? My two initial thoughts are:
-- Example lazy setup
{
'ricardoramirezr/blade-nav.nvim',
dependencies = {
'hrsh7th/nvim-cmp',
},
opts = {
components_paths = {
"resources/views/components",
"resources/views/common"
}
},
}
.nvim.blade-nav
:
resources/views/components
resources/views/common
I like the second, the first one is to global in my opinion, not all project has the same.
The second one but using defaults on exrc
sound better to me. if exrc
is on, Neovim will pick it automatically, you can have other options there also.
Ah okay, yeah didn't realize exrc
had other benefits. Fairly new to nvim and haven't seen it before. Sounds good!
@tylerdak, @gmnz take a look at main
, you can use any exrc
file supported since neovim will read it automatically. i.e. .nvim.lua
vim.g.blade_nav = {
laravel_componets = {
"resources/views/common",
}
}
And let me know
That works for me!
For anyone else, if you haven't used exrc
before, it needs to be enabled somewhere in your nvim config:
vim.o.exrc = true
Lets wait one week to see if there is any issue, and then I'll make a release
Hi,
So basically the problem is described in the tittle. gf doesn't work for me at all, always gives me the error mentioned above. Any ideas why this could be? The views are in these dirs:
resources/views/{common components errors staremesto vendor}
Is there any way I can help the plugin find them?