vim-laravel icon indicating copy to clipboard operation
vim-laravel copied to clipboard

gf for routes

Open FatBoyXPC opened this issue 5 years ago • 7 comments

It would be awesome if gf while inside route('route.name') would take the user to the route handler. I figure maybe this feature could leverage artisan route:list behind the scenes. This might be tough for closure routes since we'd likely have to parse out the various route files manually, which might be named differently. The router has a base_path() option, so we could look into seeing if it stores that state anywhere, but even then, I was on a project that looped over a set of files in a directory and did a plain ol' require in the RouteServiceProvider.

I think this would also be cool for url() but I'm not sure how hard it would be to compare url("foo/bar/{$user->id}") to Route::get('foo/bar/{user}').

FatBoyXPC avatar Feb 28 '19 16:02 FatBoyXPC

It would be awesome if gf would take the user to the route handler.

gf on what, though?

noahfrederick avatar Mar 02 '19 02:03 noahfrederick

Oh, good point. I meant route('route.name'). I'll edit the original post to include this. I thought about the url() helper as well, but I'm not sure how easy it would be to compare the route definition with the {foo} style variables with url("/users/{$user->id}").

FatBoyXPC avatar Mar 02 '19 02:03 FatBoyXPC

I meant route('route.name').

I feel it would be more intuitive for this to jump to the respective routes file, although either way, we would really be stretching the semantics of gf quite a bit. Then again, I've already set a precedent with the go-to translation/config stuff. Ugh.

I thought about the url() helper as well, but I'm not sure...

Yeah, I'm going to take a pass on trying to get that working. 😄

noahfrederick avatar Mar 02 '19 03:03 noahfrederick

I'm not entirely sure how we'd get to the routes file, especially if there was some custom routes handling. If you're up for pairing - I'd totally be down to pair on this! I've got some free time right now since you seem active!

FatBoyXPC avatar Mar 02 '19 03:03 FatBoyXPC

I've got a little time. What do you have in mind?

Yeah, I think the routes file idea is maybe not feasible, short of doing some ugly scraping with regexes.

noahfrederick avatar Mar 02 '19 03:03 noahfrederick

I figured screensharing if you were down, I wouldn't be much use other than maybe helping figure out how Laravel's router works, though. Vimscript and I do not get along :P

FatBoyXPC avatar Mar 02 '19 03:03 FatBoyXPC

Shoot me an email at [email protected].

noahfrederick avatar Mar 02 '19 03:03 noahfrederick