Nvim
LazyVim based config for NeoVim with PHP/Python IDE features (including step debugging). I mainly use Emacs but having this as a backup in case it breaks and sometimes just for collaborative tmux coding sessions.
Install / Use
/learn @jasalt/NvimREADME
NeoVim IDE config based on LazyVim starter template.
Using standard DAP, LSP and tree-sitter providing near identical capabilities to VSCode/Codium.
Tested mainly with PHP and secondarily with Python.
Custom additions worth a separate mentioning
- High contrast white theme
lua/plugins/theme.lua - Treesitter-context
lua/plugins/treesitter-context.lua - PHP Intelephense LSP with k&r formatting option
lua/plugins/lsp.lua(for WP code style) - VSCode nvim plugin aware DAP setup
init.lua
Install notes
git clone https://github.com/jasalt/nvim.git ~/.config/nvim
nvim
Usage with tmux
Run :checkhealth command to see possible issues with configuration.
Example configuration for truecolor support in case of color rendering fails (tmux 3.0a)
# ~/.tmux.conf
set -sg escape-time 10
set-option -g focus-events on
# True color settings
set -g default-terminal "screen-256color"
set -ag terminal-overrides ",$TERM:Tc"
Nerdicons / icons in file browser
Custom font icons may not load with messed up locale configuration. Running tmux with -u flag can help as temporary fix eg. tmux -u a.
Usage without access to C-compiler (experimental)
Zig compiler (https://ziglang.org/download/) is easy to install to path, but for some tree-sitter parsers that fail compiling with it, they can be compiled elsewhere and moved to nvim install path eg. with extracted release archive in nvim-linux64/lib/nvim/parser/.
Eg. rsync -av ~/.local/share/nvim/lazy/nvim-treesitter/parser/twig.so <hostname>:~/bin/nvim-linux64/lib/nvim/parser/.
Debugging PHP
Nvim should be started in WordPress root folder so that LSP finds all definitions etc.
Afterwards sidebar tree view root can be adjusted with . to hide unnecessary files.
Default breakpoints on exceptions, errors etc. can be modified in init.lua by setting dap.defaults.php.exception_breakpoints value.
Debugger example
Debugging PHP backend code (WordPress plugin) serving data to a HTMX front-end view. Server runs on VVV Vagrant development VM.
HTMXPress live search demo with "t" typed into live search box
Request intercepted by XDebug with step-debugging, interactive evaluation etc:
Custom Keybindings Cheat Sheet
Space is the <leader> key and regular VIM motions are otherwise expected, mostly following LazyVim starter config bindings.
Editing
| Go To Definition | gd | | Delete buffer | <leader>bd |
Debugging
| Add Breakpoint | <leader>db | <leader>F5 | | Start Debugger (continue) | <leader>dc | | | Stop on all (default) | <leader>dA | | | Stop on all but notify | <leader>da | | | Stop on none but breakpoint | <leader>d0 | | | Show / Hide DAP UI | <leader>du | |
Misc
| Toggle folder tree view | <leader>e | | Disable indent on save | <leader>uf |
Notes
Made by NeoVim novice, includes mindlessly copy pasted code from various source. Refer to LazyVim docs and discussions etc to understand the overall structure better.
Readme, repo commit messages and some parts of code included are written with Emacs.
More notes while figuring this out on LazyVim discussions.
Todo
- how to eval configuration functions during runtime?
- fix indenting issues
- https://neovim.io/doc/user/indent.html#_html
- https://www.josean.com/posts/nvim-treesitter-and-textobjects
