A comprehensive Laravel development environment for Neovim with focus on IDE Helper integration
Features • Requirements • Installation • Configuration • Usage • Contributing • Discussions
⚠️ WARNING: PRE-ALPHA SOFTWARE ⚠️
This plugin is in very early development (first commit, day one). It is currently in the "it works on my machine" phase and has not been thoroughly tested across different environments. Use at your own risk.
The primary goal of this plugin is to create a unified Laravel development experience in Neovim by integrating with the broader Laravel for Neovim ecosystem. This means:
Projects we aim to integrate with include:
The following plugins provide the enhanced command interface with subcommands and automatic help:
Without mega.cmdparse, the plugin will fall back to the legacy command interface. Without telescope.nvim, the plugin will fall back to simple input prompts for Artisan commands.
Important: To prevent autocompletion interference in Telescope prompts and artisan output windows, you need to disable completion in these filetypes:
-- For blink.cmp users
require('blink.cmp').setup({
-- Other configuration options...
enabled = function()
local ignore_filetypes = {"TelescopePrompt", "TelescopeResults", "artisan-output"}
return not vim.tbl_contains(ignore_filetypes, vim.bo.filetype)
end,
})
-- For nvim-cmp users
-- Disable for each filetype individually
require("cmp").setup.filetype("TelescopePrompt", { enabled = false })
require("cmp").setup.filetype("TelescopeResults", { enabled = false })
require("cmp").setup.filetype("artisan-output", { enabled = false })
For a complete Laravel development environment, we recommend the following plugins:
{
"greggh/laravel-helper.nvim",
dependencies = {
-- Enhanced command interface
"ColinKennedy/mega.cmdparse", -- Optional but recommended
"ColinKennedy/mega.logging", -- Required by mega.cmdparse
-- Core dependencies
"MunifTanjim/nui.nvim",
-- Telescope integration
"nvim-telescope/telescope.nvim",
"nvim-telescope/telescope-fzf-native.nvim",
"nvim-lua/plenary.nvim", -- Required by telescope
-- Additional recommended Laravel ecosystem dependencies
"folke/lazy.nvim",
"nvim-neotest/nvim-nio",
"neovim/nvim-lspconfig",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer",
"nvim-treesitter/nvim-treesitter",
"windwp/nvim-ts-autotag",
"nvim-treesitter/nvim-treesitter-context",
"nvim-treesitter/nvim-treesitter-textobjects",
"stevearc/conform.nvim",
"mfussenegger/nvim-lint",
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
"nvim-neotest/neotest",
"nvim-neotest/neotest-plenary",
"V13Axel/neotest-pest",
"L3MON4D3/LuaSnip",
"rafamidriz/friendly-snippets",
"saghen/blink.cmp",
"saghen/blink.compat",
"mikavilpas/blink-ripgrep.nvim",
"dmitmel/cmp-cmdline-history",
},
ft = { "php", "blade" },
config = function()
require("laravel-helper").setup({
-- Optional configuration options
})
end,
}
use {
'greggh/laravel-helper.nvim',
requires = {
-- Enhanced command interface
'ColinKennedy/mega.cmdparse', -- Optional but recommended
'ColinKennedy/mega.logging', -- Required by mega.cmdparse
-- Core dependencies
'MunifTanjim/nui.nvim',
},
config = function()
require('laravel-helper').setup()
end
}
" Core and enhanced command interface
Plug 'MunifTanjim/nui.nvim'
Plug 'ColinKennedy/mega.logging' " Required by mega.cmdparse
Plug 'ColinKennedy/mega.cmdparse' " Optional but recommended
Plug 'greggh/laravel-helper.nvim'
" Then in your init.vim
lua require('laravel-helper').setup()
require("laravel-helper").setup({
-- Whether to automatically detect Laravel projects and offer IDE Helper generation
auto_detect = true,
-- Default timeout for Sail/Docker operations (in milliseconds)
docker_timeout = 360000, -- 6 minutes
-- Whether to automatically use Sail when available
prefer_sail = true,
-- Commands to run for IDE Helper generation
commands = {
"ide-helper:generate", -- PHPDoc generation for Laravel classes
"ide-helper:models", -- PHPDoc generation for models
"ide-helper:meta", -- PhpStorm Meta file generation
}
})
By default, the plugin doesn't set any key mappings. You can add your own like this:
vim.api.nvim_create_autocmd("FileType", {
pattern = "php",
callback = function()
-- Only set up mappings in Laravel projects
if require("laravel-helper").is_laravel_project() then
local opts = { buffer = 0, silent = true }
-- Generate IDE Helper files
vim.keymap.set("n", "<leader>lph", function()
require("laravel-helper").generate_ide_helper(true)
end, vim.tbl_extend("force", opts, { desc = "Generate Laravel IDE Helper files" }))
-- Install IDE Helper if not already installed
vim.keymap.set("n", "<leader>lpi", function()
require("laravel-helper").install_ide_helper()
end, vim.tbl_extend("force", opts, { desc = "Install Laravel IDE Helper" }))
-- Toggle debug mode for Laravel IDE Helper
vim.keymap.set("n", "<leader>lpd", function()
require("laravel-helper").toggle_debug_mode()
end, vim.tbl_extend("force", opts, { desc = "Toggle Laravel IDE Helper debug mode" }))
-- Run Artisan commands
vim.keymap.set("n", "<leader>lpa", function()
require("laravel-helper").run_artisan_command()
end, vim.tbl_extend("force", opts, { desc = "Run Laravel Artisan command" }))
end
end,
})
When the plugin is installed with the optional mega.cmdparse dependency, it provides a structured command interface:
:Laravel artisan <args> - Run Laravel Artisan commands
:Laravel ide-helper generate - Generate Laravel IDE Helper files
:Laravel ide-helper generate --use-sail - Generate IDE Helper files using Sail
:Laravel ide-helper install - Install Laravel IDE Helper package
:Laravel ide-helper debug - Toggle debug mode for IDE Helper
Use :Laravel --help
to see all available commands and their descriptions.
When the plugin is installed with telescope.nvim, it provides enhanced selection interfaces:
:LaravelTelescope artisan - Browse and run Artisan commands with fuzzy finder
:LaravelTelescope routes - Browse Laravel routes with fuzzy finder
:LaravelTelescope models - Browse Laravel models with fuzzy finder
The plugin also automatically uses Telescope for the Artisan command input when you call functions like run_artisan_command()
without a specific command.
:LaravelArtisan <args> - Run Laravel Artisan commands
:LaravelGenerateIDEHelper [php|sail] - Generate Laravel IDE Helper files
:LaravelInstallIDEHelper - Install Laravel IDE Helper package
:LaravelIDEHelperToggleDebug - Toggle debug mode for IDE Helper
is_laravel_project()
: Check if current directory is a Laravel projectinstall_ide_helper()
: Install Laravel IDE Helper packagegenerate_ide_helper(force)
: Generate IDE Helper filestoggle_debug_mode()
: Toggle detailed debug outputrun_artisan_command(command)
: Run an artisan command with output capturewith_sail_or_php(command)
: Run a command using Sail when available, falling back to PHPget_sail_or_php_command(command)
: Get the command string to run with either Sail or standard PHPContributions are welcome! Please check out our contribution guidelines for details on how to get started.
For a complete guide on setting up a development environment, installing all required tools, and understanding the project structure, please refer to DEVELOPMENT.md.
The project includes comprehensive setup for development:
# Run tests
make test
# Check code quality
make lint
# Set up pre-commit hooks
scripts/setup-hooks.sh
# Format code
make format
.stylua.toml
.luacheckrc
Made with ❤️ by greggh