/nvim

LazyVim based config for NeoVim with PHP/Python IDE features (including step debugging).

Primary LanguageLuaApache License 2.0Apache-2.0

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.

Regular View 20231202

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 Demo Website using AJAX

Request intercepted by XDebug with step-debugging, interactive evaluation etc:

Debugger View with step debugging

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 | bd |

Debugging

| Add Breakpoint | db | F5 | | Start Debugger (continue) | dc | | | Stop on all (default) | dA | | | Stop on all but notify | da | | | Stop on none but breakpoint | d0 | | | Show / Hide DAP UI | du | |

Misc

| Toggle folder tree view | e | | Disable indent on save | 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