blade-lsp
v0.1.1
Published
Language Server Protocol implementation for Laravel Blade templates
Downloads
218
Maintainers
Readme
Laravel Blade LSP
Built with TypeScript, Node.js, and tree-sitter-blade.
Installation (Development)
# Clone the repository
git clone https://github.com/gcavanunez/blade-lsp.git
cd blade-lsp
# Install dependencies (includes native tree-sitter build)
npm install
# Build
npm run buildNeovim Configuration
Mason (Recommended)
Install via Mason using the blade-lsp-mason registry:
require("mason").setup({
registries = {
"github:gcavanunez/blade-lsp-mason",
"github:mason-org/mason-registry",
},
})Run :MasonUpdate to refresh registries, then :MasonInstall blade-lsp.
Once installed, configure the LSP using vim.lsp.config (Neovim 0.11+):
vim.lsp.config('blade_lsp', {
cmd = { 'blade-lsp', '--stdio' },
filetypes = { 'blade' },
root_markers = { 'composer.json', 'artisan', '.git' },
})Manual
If you prefer not to use Mason, clone and build the project, then point directly to the built server:
vim.lsp.config('blade_lsp', {
cmd = { 'node', '/path/to/blade-lsp/dist/server.js', '--stdio' },
filetypes = { 'blade' },
root_markers = { 'composer.json', 'artisan', '.git' },
})Update /path/to/blade-lsp/dist/server.js to the actual path where you cloned and built the project.
Initialization Options
You can pass init_options to configure the LSP server's behavior:
vim.lsp.config('blade_lsp', {
cmd = { 'node', '/path/to/blade-lsp/dist/server.js', '--stdio' },
filetypes = { 'blade' },
root_markers = { 'composer.json', 'artisan', '.git' },
init_options = {
-- string[]|nil (default: auto-detected)
-- Explicit command array to execute PHP. When omitted, the server
-- auto-detects by probing: Herd, Valet, Sail, Lando, DDEV, Local, Docker.
phpCommand = { 'docker', 'compose', 'exec', '-T', 'app', 'php' },
-- "herd"|"valet"|"sail"|"lando"|"ddev"|"local"|"docker"|nil (default: auto-detected)
-- Preferred PHP environment. When set, skips auto-detection and
-- tries only the specified environment.
phpEnvironment = 'docker',
-- boolean|nil (default: true)
-- Enables Laravel project integration (views, components, custom directives
-- via PHP). Set to false for standalone Blade support only.
enableLaravelIntegration = true,
},
})Credits
This project draws inspiration from and utilities from:
License
MIT
