Navigating Blade views, components, routes and configs within Laravel projects
blade-nav.nvim
is a Neovim plugin designed to enhance navigation within
Laravel projects. It allows quick access to Blade views and their corresponding
classes, enables navigation to the controller associated with a route name, and
to configuration files.
This plugin simplifies moving between controllers, routes, configuration files,
Blade views, and components in Laravel applications.
@extends('name')
@include('name')
<x-name />
<livewire:name />
or @livewire('name')
Open Blade views from controller or route definitions like
Route::view('url', 'name')
View::make('name')
view('name')
route('name')
or to_route('name')
config('file.key')
gf
(goto file) command for navigation.To get started with blade-nav.nvim
, add the plugin to your init.lua
or init.vim
file:
Using packer:
use {
"ricardoramirezr/blade-nav.nvim",
requires = {
"hrsh7th/nvim-cmp", -- if using nvim-cmp
{ "ms-jpq/coq_nvim", branch = "coq" }, -- if using coq
},
ft = { "blade", "php" },
config = function()
require("blade-nav").setup({
cmp_close_tag = true, -- default: true
})
end,
}
Using lazy:
{
'ricardoramirezr/blade-nav.nvim',
dependencies = { -- totally optional
'hrsh7th/nvim-cmp', -- if using nvim-cmp
{ "ms-jpq/coq_nvim", branch = "coq" }, -- if using coq
},
ft = {'blade', 'php'}, -- optional, improves startup time
opts = {
close_tag_on_complete = true, -- default: true
},
}
Place the cursor over the file name and use the gf
command.
php artisan make:livewire
.php artisan make:component
. AIf the file does not exist and is in a subfolder that does not exist yet, you should create the directory, it can be done writing the file using
++p
To navigate to a controller associated with a route name:
gf
command.To navigate to a configuration file:
gf
command.Select an existing resource using the custom source, write either:
in a Blade file:
@extends('
@include('
<x-
<livewire:
@livewire('
in a Controller or Route:
Route::view('
View::make('
view('
in any PHP or Blade file:
route('
to_route('
And the list of files will appear, and with the magic of completion the list if filtered while you write.
No additional configuration is required. The plugin works out-of-the-box with the default gf
command.
For cmd you should install the plugin.
For coq, you should install the plugin,
coq_settings.match.max_results
limits the result shown.
For completion to place nice with autopairs, you can set the
close_tag_on_complete
to false, blade-nav will not close the tag on complete.
close_tag_on_complete = false, -- default: true
For packages that has Blade components, you should run the Ex command
BladeNavInstallArtisanCommand
to install the artisan command.
If you want blade-nav
to search in other paths when using gf
on a Laravel
component, you can specify this by enabling the exrc
option and adding to one
of the supported files, i.e.:
vim.g.blade_nav = {
laravel_components = {
"resources/views/common",
},
}
See :h VIMINIT
To check the health of the plugin, run :checkhealth blade-nav
.
Feel free to submit issues or pull requests to enhance the functionality of this plugin.
This plugin is open-source and distributed under the MIT License. See the LICENSE file for more details.
Special thanks to the Neovim and Laravel communities for their continuous support and contributions.