Hey there! π This is my carefully crafted Neovim configuration that I've been using and refining while working on Laravel projects. After trying countless setups and configurations, this one finally feels just right - it's fast, smart, and makes Laravel development a breeze.
What makes it special? It's got everything I need for Laravel work - from super-smart PHP completion (thanks to Intelephense via CoC) to Blade template support, and it handles all those little things that used to slow me down. And yes, it works great with Tailwind CSS too!
I originally built this for myself, but figured it might help other Laravel devs who want to give Neovim a shot. Feel free to fork this repository and customize it to your liking.
Before starting, make sure you have the following installed:
-
Neovim (version 0.8.0 or higher)
# For macOS (using Homebrew) brew install neovim # For Ubuntu/Debian sudo apt install neovim
-
Node.js (required for CoC)
# For macOS brew install node # For Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt install nodejs
-
Git
# For macOS brew install git # For Ubuntu/Debian sudo apt install git
-
PHP (required for Intelephense language server)
# For macOS brew install [email protected] # For Ubuntu/Debian sudo apt install php8.2-cli php8.2-mbstring php8.2-xml
-
Composer (PHP package manager for Laravel development)
# For macOS brew install composer # For Ubuntu/Debian curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
-
Ripgrep (for better search functionality with Telescope)
# For macOS brew install ripgrep # For Ubuntu/Debian sudo apt install ripgrep
-
fd (for faster file finding with Telescope)
# For macOS brew install fd # For Ubuntu/Debian sudo apt install fd-find # Note: On Ubuntu/Debian, you may need to alias fd to fdfind # Add to your shell config: alias fd=fdfind
-
Intelephense Language Server (required for PHP code intelligence)
npm install -g intelephense
-
Code formatters (for
formatter.nvimand PHP LSP formatting):- PHP: Formatting is handled by Intelephense (via CoC language server). Its style (e.g., brace style set to
per, which is K&R style) is configured withincoc-settings.json(seeintelephense.format.braces). Ensure@yaegassy/coc-intelephenseCoC extension is installed. You can still use project-specific tools like Laravel Pint or PHP-CS-Fixer independently.
# Example: If you want PHP-CS-Fixer globally for other uses # composer global require friendsofphp/php-cs-fixer
- JavaScript, TypeScript, JSON, HTML, CSS, Vue, YAML (Prettier)
npm install -g prettier
- Bash/Shell (shfmt)
# macOS brew install shfmt # Linux (Go needs to be installed) # Ensure Go is installed, then: go install mvdan.cc/sh/v3/cmd/shfmt@latest
- Lua (StyLua)
# macOS brew install stylua # Linux (Rust/Cargo needs to be installed) # Ensure Rust/Cargo is installed, then: cargo install stylua
- Python (Black)
pip install black # or pip3 install black - PHP: Formatting is handled by Intelephense (via CoC language server). Its style (e.g., brace style set to
-
(Optional) Github Copilot. If you want to use Copilot, you can follow the installation setup. https://github.com/github/copilot.vim
# Start setup :Copilot setup
-
First, install vim-plug (Plugin Manager):
# For Unix (Linux/macOS) sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
-
Create the Neovim configuration directory:
# For Unix (Linux/macOS) mkdir -p ~/.config/nvim
-
Copy the provided
init.vimandcoc-settings.jsoninto your Neovim configuration directory:# For Unix (Linux/macOS) cp init.vim coc-settings.json ~/.config/nvim/
(Ensure
coc-settings.jsonis placed in~/.config/nvim/coc-settings.jsonfor CoC to pick it up automatically. If CoC looks for it in a different location, you might need to adjust or symlink it). -
Open Neovim and install plugins:
nvim
Then inside Neovim, run:
:PlugInstall -
Install CoC extensions (this will happen automatically when you open Neovim, based on
g:coc_global_extensionsininit.vim). You can verify with:CocList extensions.
- π§ Intelligent code completion (CoC + Intelephense for PHP, TSServer for JS/TS, Copilot for AI suggestions)
- π Fuzzy file finding and searching (Telescope with
fdandripgrep) - π File explorer (nvim-tree)
- π¨ Beautiful UI with Tokyo Night theme and Bufferline for tab-like buffer management
- π Enhanced status line (Lualine)
- β¨οΈ Git integration in the gutter (Gitsigns)
- π‘ Function signature help (
lsp_signature.nvim) - π¦ Auto-pairs and easy line/selection moving (via
mini.nvimcollection) - π Surround functionality (
vim-surround) - π³ Better syntax highlighting (TreeSitter with support for PHP, HTML, CSS, JavaScript, TypeScript, JSON, Lua, Python, Bash, and YAML)
- β‘ Performance optimizations (lazy redraw, optimized regex engine, increased memory limits)
- π¨ Powerful multi-language code formatting (
formatter.nvimfor many languages, CoC/Intelephense for PHP) - π§ PHP-specific tools including
coc-php-cs-fixerfor additional formatting options
Space is the leader key. Here are some essential keybindings to get you started:
<Space>ff- Find files (Telescope)<Space>fg- Live grep (search in files with Telescope)<Space>fb- Browse buffers (Telescope)<Space>fh- Browse help tags (Telescope)<Space>e- Toggle file explorer (nvim-tree)
gd- Go to definition (CoC)gy- Go to type definition (CoC)gi- Go to implementation (CoC)gr- Find references (CoC)Kor<C-Space>(in Normal mode) - Show documentation/hover (CoC)
<Space>rn- Rename symbol (CoC)<Space>ac- Code action menu<Space>aC- Code action menu at cursor<Space>ac(in Visual mode) - Code action for selected region
<Space>a- Show all diagnostics (CoC)[g- Go to previous diagnostic]g- Go to next diagnostic
Ctrl + Up/Down/Left/Right- Navigate between windows<Space>qq- Quit Neovim<Space>bd- Close current buffer[band]b- Previous/Next buffer
Ctrl + Space(in Insert mode) - Trigger completion / Refresh completionTab/Shift + Tab- Navigate completion menuEnter- Select completion
<Space>f- Format current buffer usingformatter.nvim(via the:Formatcommand):- For PHP files: Uses Intelephense formatting via CoC (
vim.fn.CocAction('format')) - For other filetypes: Uses their respective formatters (Prettier, Black, StyLua, etc.)
- For PHP files: Uses Intelephense formatting via CoC (
<Space>F- Format current buffer and save usingformatter.nvim(via the:FormatWritecommand)<Space>fs(in Visual mode) - Format selected region using CoC (<Plug>(coc-format-selected)).
Ctrl + Shift + Up/Down/Left/Right- Move current line or visual selection
Ctrl + J- Accept suggestionCtrl + n- Next suggestionCtrl + p- Previous suggestionCtrl + \- Dismiss suggestion
Esc- Clear search highlighting<Space>c- Show CoC commands<Space>o- Show symbols/outline (CoC)
The configuration includes formatting support for:
| Language | Formatter / Method | Notes |
|---|---|---|
| PHP | Intelephense (via CoC) | Uses CoC formatting (vim.fn.CocAction('format')). Style (e.g., brace style per) configured in coc-settings.json. |
| JavaScript | Prettier | Via formatter.nvim |
| TypeScript | Prettier | Via formatter.nvim |
| JSON | Prettier | Via formatter.nvim |
| HTML | Prettier | Via formatter.nvim |
| CSS | Prettier | Via formatter.nvim |
| Vue | Prettier | Via formatter.nvim |
| YAML | Prettier | Via formatter.nvim |
| Python | Black | Via formatter.nvim |
| Bash/Shell | shfmt | Via formatter.nvim |
| Lua | StyLua | Via formatter.nvim |
| Vim | Built-in | Removes trailing whitespace via formatter.nvim |
| Others | Built-in | Removes trailing whitespace via formatter.nvim |
The configuration includes:
- Case-insensitive search (smartcase enabled)
- 4-space indentation (softtabstop, shiftwidth, tabstop all set to 4)
- Line numbers with relative numbering
- True color support (
termguicolors) - Mouse support in all modes
- System clipboard integration (
unnamedplus) - Persistent undo history
- Tokyo Night theme with custom background color set to pure black
The configuration includes several performance enhancements:
- Lazy redraw (
lazyredraw) - Prevents unnecessary screen redraws during macros - Fast terminal connection (
ttyfast) - Optimizes for modern terminals - Syntax column limit (
synmaxcol=3000) - Limits syntax highlighting to 3000 columns for better performance - Extended redraw time (
redrawtime=10000) - Allows more time for syntax highlighting on complex files - Increased memory limit (
maxmempattern=2000000) - Higher memory allocation for pattern matching - New regex engine (
re=0) - Uses the newer, more efficient regex engine - Optimized completion (
updatetime=300) - Faster completion popup response
-
Missing Plugins:
- Run
:PlugInstallinside Neovim. - Restart Neovim.
- Run
-
CoC Errors or Issues:
- Ensure Node.js is installed and accessible.
- Run
:CocInfoto check CoC status and paths. - Run
:CocList extensionsto see installed CoC extensions. If@yaegassy/coc-intelephenseor other expected extensions are missing or have errors, try:CocInstall @yaegassy/coc-intelephenseor:CocUpdatefor all. - Check
coc-settings.jsonis correctly placed (e.g.,~/.config/nvim/coc-settings.json).
-
File Icons Not Showing (nvim-tree, Telescope, etc.):
- Make sure you have a Nerd Font installed and configured in your terminal emulator.
-
Telescope Search Not Working:
- Verify
ripgrep(forlive_grep) andfd(forfind_files, optional but recommended in config) are installed and in yourPATH. - Run
rg --versionandfd --versionin your terminal to confirm.
- Verify
-
Code Formatting Isn't Working:
- Check if the required global formatters (Prettier, shfmt, Black, StyLua) are installed and in your
PATH. See "Prerequisites" section. - For PHP:
- Ensure
@yaegassy/coc-intelephenseCoC extension is active (:CocList extensions). - PHP formatting uses Intelephense via
formatter.nvim'svim.fn.CocAction('format')call. Check:CocInfofor LSP status and:CocOpenLogfor Intelephense-specific messages or errors. - The
coc-settings.jsonfile configures Intelephense; ensure it's loaded.
- Ensure
- For all languages (using
formatter.nvim):- The keymaps
<Space>f(runs:Format) and<Space>F(runs:FormatWriteand saves) useformatter.nvimfor full buffer formatting. - For formatting a visual selection, use
<Space>fswhich uses CoC. - If
formatter.nvimisn't working as expected with<Space>for<Space>F, check:messagesfor any errors fromformatter.nvim. - You can increase
formatter.nvimlog level ininit.vimfor more details if needed.
- The keymaps
- Check if the required global formatters (Prettier, shfmt, Black, StyLua) are installed and in your
-
UI Elements (Lualine, Bufferline) Missing/Broken:
- Ensure plugins are installed (
:PlugInstall). - Check
:messagesfor any Lua errors related to these plugins during startup.
- Ensure plugins are installed (
For more detailed troubleshooting, check the output of:
:messages:CocInfo:CocOpenLog(for CoC related issues):checkhealth(provides diagnostics for Neovim and some plugins)
If you encounter any issues:
- Run
:checkhealthinside Neovim to diagnose common problems. - Check if all prerequisites are installed correctly.
- Make sure your Neovim version is 0.8.0 or higher (
:version).