Compare commits

...

62 Commits

Author SHA1 Message Date
Ray Elliott b473cc6d15 Add toggle for diagnostic display in keymaps
This change introduces a new keymap to toggle the display of
diagnostics, enhancing user control over diagnostic visibility.
2025-12-12 01:17:07 +00:00
Ray Elliott 670450dccb Add command search functionality to Telescope keymaps
This update introduces a new key mapping for searching commands
within Telescope, enhancing the usability of the fuzzy finder.
2025-12-12 01:09:02 +00:00
Ray Elliott f4f6260b20 Refine keymap descriptions for clarity and consistency
Updated keymap descriptions across various plugins to include
specific prefixes for better identification and organization.
2025-12-12 01:00:25 +00:00
Ray Elliott 99ea741fbb Add note about global ESLint configuration fallback
Clarify that ~/.eslintrc.json serves as a global fallback
when no project-specific ESLint configuration exists.
2025-12-12 00:29:18 +00:00
Ray Elliott 8a24bbb656 Add ESLint configuration for JavaScript files
This introduces a flat ESLint configuration for JavaScript,
MJS, and CJS files, including recommended rules and global
variables for both browser and Node.js environments.
2025-12-12 00:23:15 +00:00
Ray Elliott 949cc32d0b Add muted colors for quickfix diagnostic highlighting
Updated quickfix/location list colors to use muted tones
for better contrast and visibility, aligning with git/diff
styles. Adjusted diagnostic severity highlighting to
reflect these changes.
2025-12-12 00:02:16 +00:00
Ray Elliott 3f4430eb82 Update diagnostic severity highlighting in quickfix list
Change background colors for diagnostic severity groups
to improve visibility in quickfix and location lists.
2025-12-11 23:57:40 +00:00
Ray Elliott bd89c05068 Add diagnostic severity highlighting for quickfix lists
Enhance visibility of diagnostic messages in quickfix and location
lists by adding custom syntax groups for error, warning, info,
hint, and note.
2025-12-11 23:56:10 +00:00
Ray Elliott f2a94d10ac Add LSP diagnostic backgrounds for better visibility
Introduce light tinted backgrounds for LSP diagnostics
to enhance code highlighting and improve user experience.
2025-12-11 23:45:02 +00:00
Ray Elliott 5acb2cc169 Update LSP colors for better visibility and clarity
Refine diagnostic colors to use fluorescent tones for errors,
warnings, and hints, enhancing visibility in the editor.
2025-12-11 23:36:29 +00:00
Ray Elliott b0a172647a Remove background colors from virtual text diagnostics
Updated LSP diagnostic virtual text settings to remove
background colors for better visibility and consistency.
2025-12-11 23:15:08 +00:00
Ray Elliott 6540e4cee4 use system managed lua-language-server 2025-12-11 23:12:07 +00:00
Ray Elliott dd8cc0eaf2 Add LSP diagnostic test files for multiple languages
Includes test files for Lua, JavaScript, PHP to verify the Paper Tonic
Modern colorscheme's diagnostic virtual text colors across different
LSPs and their expected diagnostics.
2025-12-11 23:05:26 +00:00
Ray Elliott db8d67a6b7 Update colorscheme configuration and cleanup legacy files
- Updated `lua/plugins/colorscheme.lua` to load `paper-tonic-modern`
- Moved old `paper-tonic/` directory to `legacy/paper-tonic-original/`
- Validated full config reload; all highlight groups load correctly
- No separate overrides needed with modern implementation
2025-12-11 22:52:54 +00:00
Ray Elliott e08ca2e42c add plugin highlight groups to colourscheme 2025-12-11 22:12:03 +00:00
Ray Elliott e538a0b150 update css pseudo slector colors 2025-12-11 21:56:16 +00:00
Ray Elliott 3ad385e285 Refactor Paper Tonic Modern colorscheme and enhance semantic highlighting
- Updated highlights.scm to improve CSS, HTML, and data attribute captures with higher priority.
- Added a new Lua function to display highlight group and color information under the cursor.
- Expanded editor, semantic, syntax, and TreeSitter highlight groups for better visual consistency across languages.
- Created test files for PHP, HTML, CSS, and Lua to validate syntax highlighting.
- Implemented a shell script to test semantic highlights in a Neovim session.
- Simplified colorscheme loading process by removing unnecessary plugin specifications.
2025-12-11 21:47:27 +00:00
Ray Elliott 61400a7c9b create colour scheme tructure 2025-12-11 20:30:41 +00:00
Ray Elliott 2b558d4e4d extract colours from legacy colour scheme 2025-12-11 20:15:14 +00:00
Ray Elliott a2ec276705 revise colorscheme integration plan for Paper Tonic
- Update phases for modern Paper Tonic colorscheme
- Outline decisions and tasks for extraction and structure
- Include validation and plugin configuration steps
2025-12-08 01:16:41 +00:00
Ray Elliott cd80d074b4 activate legacy colour scheme 2025-12-08 01:07:06 +00:00
Ray Elliott 651c7999e6 activate legacy colour scheme 2025-12-08 01:06:58 +00:00
Ray Elliott bbe744339d add phase for colorscheme migration
Paper Tonic colorscheme and custom highlights

- Port Paper Tonic colorscheme as a local plugin.
- Add custom TreeSitter captures for CSS and HTML.
- Verify and extend highlights for plugins and captures.
- Retire legacy highlights and validate performance.
2025-12-08 00:35:08 +00:00
Ray Elliott a0d94be4f3 add keyword settings 2025-12-08 00:18:47 +00:00
Ray Elliott e94c3cb923 update diagnostic signs configuration
Refactor the diagnostic signs setup to use a structured
table for severity levels, improving clarity and maintainability.
2025-12-08 00:10:32 +00:00
Ray Elliott fc250c0be2 add abbreviations 2025-12-08 00:06:52 +00:00
Ray Elliott a57f72f7c7 show pyright errors 2025-12-07 23:53:32 +00:00
Ray Elliott b56d703662 fix ruff/Ruff duplication 2025-12-07 23:48:11 +00:00
Ray Elliott 0685135ccf copnfigure folding 2025-12-07 23:20:15 +00:00
Ray Elliott b9d9f7e264 configure python 2025-12-07 23:12:35 +00:00
Ray Elliott b045d7c627 configure formatters and linters 2025-12-07 22:33:00 +00:00
Ray Elliott c47afa2471 configure copilot 2025-12-07 22:03:35 +00:00
Ray Elliott 9a81bc88cf Merge branch 'modern-restart' of ssh://git.rayelliott.dev:3222/dots/nvim into modern-restart 2025-12-07 21:31:16 +00:00
Ray Elliott e10cff79d8 gitsigns configured 2025-12-07 21:31:02 +00:00
Ray Elliott ec7f21c81b gitsigns configured 2025-12-07 21:30:13 +00:00
Ray Elliott b3f4e6badb update migration plan for Git and Copilot integration
- Refactor phases for Git integration and Copilot setup.
- Add decisions and tasks for Gitsigns and Copilot configuration.
- Adjust phase numbering and confirm priorities for new tasks.
2025-12-07 21:26:55 +00:00
Ray Elliott 9a03d01844 ux and editing plugins configured 2025-12-07 21:18:09 +00:00
Ray Elliott ab42f6cebc configure comment.nvim 2025-12-07 21:00:09 +00:00
Ray Elliott 907331f4f2 configure treesitter 2025-12-07 20:44:49 +00:00
Ray Elliott 443364e23e oil.nvim configured 2025-12-07 20:18:45 +00:00
Ray Elliott 02df315571 update 2025-12-07 20:02:17 +00:00
Ray Elliott 8bde5cc4d3 update 2025-12-07 19:54:33 +00:00
Ray Elliott 71beb0fb78 fix project settings regression 2025-12-07 19:50:54 +00:00
Ray Elliott 976949c6f4 update 2025-12-07 19:26:31 +00:00
Ray Elliott c46b0db519 telescope configured 2025-12-07 19:26:13 +00:00
Ray Elliott 4dcee1703b netrw configured 2025-12-07 19:11:23 +00:00
Ray Elliott 9d10df7ed5 update 2025-12-07 19:05:18 +00:00
Ray Elliott b247db8531 update 2025-12-07 18:53:18 +00:00
Ray Elliott 770c9ae01f update 2025-12-07 18:33:51 +00:00
Ray Elliott 77ab9bf5e9 update 2025-12-07 17:38:06 +00:00
Ray Elliott 6b10b78cd0 lsp configged, external sources configged 2025-12-07 17:31:06 +00:00
Ray Elliott 6befee365b update 2025-12-06 23:50:51 +00:00
Ray Elliott 2638104bae lspconfig root detection not fixed, workaround noted 2025-12-06 23:42:44 +00:00
Ray Elliott 319c66bc0a mason + lsp config working 2025-12-06 23:16:03 +00:00
Ray Elliott 81fbb4ec14 update 2025-12-06 21:26:06 +00:00
Ray Elliott ed3cabf8b0 update 2025-12-06 21:16:25 +00:00
Ray Elliott a0049b8e06 update 2025-12-06 21:02:45 +00:00
Ray Elliott 53b6b9e7d8 update 2025-12-06 20:39:31 +00:00
Ray Elliott 37f987de76 granualise phases 2025-12-06 20:23:04 +00:00
Ray Elliott e112d0d61e add skeleton file structure 2025-12-06 19:56:33 +00:00
Ray Elliott bc35923fe2 clean up legacy files 2025-12-06 19:44:54 +00:00
Ray Elliott 638ff2812f add migration guide 2025-12-06 19:18:50 +00:00
714 changed files with 5077 additions and 24 deletions

182
.github/copilot-instructions.md vendored Normal file
View File

@ -0,0 +1,182 @@
# Neovim Config - AI Agent Instructions
## Project Overview
Modern Lua-first Neovim configuration using lazy.nvim, currently in active migration from legacy Vimscript. Target: minimal, fast, tab-per-context workflow with Neo-tree, Telescope, LSP, and Copilot.
**Critical**: Read `AGENTS.md` first—it defines all coding rules, migration strategy, and what NOT to reintroduce.
## Architecture & Files
```
~/.config/nvim/
├── init.lua # Entry point: loads settings/keymaps/autocmds, bootstraps lazy.nvim
├── lua/
│ ├── settings.lua # Non-plugin vim options (exrc, secure, spelllang, listchars)
│ ├── keymaps.lua # Non-plugin keymaps
│ ├── autocmds.lua # Non-plugin autocommands
│ ├── abbreviations.lua # Insert-mode abbreviations (typo corrections)
│ ├── netrw-config.lua # Netrw configuration
│ └── plugins/ # One file per plugin/domain (lazy.nvim specs)
│ ├── lsp.lua # LSP via vim.lsp.config + vim.lsp.enable (Neovim 0.11+)
│ ├── cmp.lua # Completion: nvim-cmp + LuaSnip
│ └── mason*.lua # LSP server installation
├── AGENTS.md # PRIMARY: All rules, migration plan, do-not-reintroduce list
├── MIGRATION_PLAN.md # Phase-by-phase checklist (source of truth for progress)
├── README.md # Decision log and design rationale
└── legacy/ # Archived Vimscript (do not edit; reference only)
```
## Critical Patterns
### 1. LSP Configuration (Phase 3 Complete)
**Modern API (Neovim 0.11+)**: Uses `vim.lsp.config()` + `vim.lsp.enable()`, NOT `require('lspconfig')[server].setup()`.
**CRITICAL (2025-12-07)**: Neovim 0.11+ does NOT support `on_new_config` callback. Use `LspAttach` autocmd instead.
```lua
-- lua/plugins/lsp.lua pattern:
-- Define config
vim.lsp.config(server_name, {
capabilities = capabilities,
-- NO on_attach here, NO on_new_config here
})
-- Enable server
vim.lsp.enable({ "lua_ls", "intelephense", ... })
-- Load project settings via LspAttach autocmd
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
-- Load .nvim.lua from client.root_dir
-- Merge into client.settings
-- Send workspace/didChangeConfiguration notification
end,
})
```
**Key decisions**:
- No neoconf (incompatible with Neovim 0.11+, issue #116)
- Native `exrc` + `secure` for project config (see settings.lua)
- Project settings loaded via `LspAttach` autocmd (NOT `on_new_config` which is deprecated)
- `workspace/didChangeConfiguration` sent after merging settings into `client.settings`
### 2. Project-Local Configuration
**Format**: `.nvim.lua` at project root, returns:
```lua
return {
lsp = {
intelephense = {
settings = {
intelephense = {
environment = {
includePaths = { "/absolute/path/to/external/lib" }
}
}
}
}
}
}
```
**Security**: `vim.opt.secure = true` prompts user before loading (one-time per file hash). Trusted files stored in `~/.local/state/nvim/trust`.
### 3. Plugin Management
- **lazy.nvim**: All plugins in `lua/plugins/` as individual files returning spec tables
- **Mason**: Installs LSP servers only; custom lspconfig setup retained
- **Plugin specs**: Use `opts = {}` for defaults, `config = function(_, opts)` for setup
- **Approval policy**: Do not install unlisted plugins without explicit user confirmation
### 4. Tab-Per-Context Workflow (Future Phase 4)
- Each tab maintains own Neo-tree root
- Splits stay within tabs
- Neo-tree: sidebar toggle + floating view + preview (no buffer pollution)
- Heavy PHP/HTML/JS/Markdown usage (WordPress plugin dev)
## Conventions
### Code Style
- **Lua APIs only**: `vim.opt`, `vim.keymap.set`, `vim.api.nvim_create_autocmd`
- **No Vimscript**: Avoid `vim.cmd` blocks unless strictly necessary
- **Keymaps**: `{ silent = true, noremap = true }` by default
- **Autocommands**: Group via `vim.api.nvim_create_augroup`, narrow scope
### File Organization
- One plugin = one file in `lua/plugins/`
- Keep plugin config self-contained in its spec
- Settings/keymaps/autocmds: only non-plugin logic in respective files
- No global state; return tables from modules
### Migration Process
1. Check `MIGRATION_PLAN.md` for current phase and priorities
2. **Before large changes**: Update plan via CLI `update_plan` tool (if available)
3. **After any change**: Immediately update `MIGRATION_PLAN.md` (check off items, add notes)
4. **After decisions**: Update `README.md` decisions log
5. Execute phases via subphases (N.x); one bullet = one implement-and-test step
6. Archive legacy files to `legacy/` instead of deleting
## Do NOT Reintroduce (from AGENTS.md)
- Custom Vimscript tabline/statusline/foldtext
- Legacy autocommands (cursorline/column per window)
- CoC or CoC-specific config
- netrw settings (Neo-tree replaces it)
- Providers for ruby/perl/node (disabled unless required)
- Auto-reload vimrc-on-write templates
- `cursorcolumn` and old folding logic (UFO will handle folding)
- neoconf plugin (incompatible with Neovim 0.11+)
## Developer Workflows
### Testing Changes
```bash
# Quick syntax check
nvim --headless -c 'lua print("Config loads")' -c 'quitall'
# Check LSP status in test workspace
cd ~/.config/nvim/WORKSPACE_TEST
nvim site/external.php # Then :LspInfo
# Validate goto-definition for external libs
# In external.php, cursor on Util::greetExternal, press gd
```
### Validation Workspaces
- `WORKSPACE_TEST/`: PHP project with `.nvim.lua` and `.git`
- `EXTERNAL_TEST/`: External library referenced via includePaths
- Test that `gd` resolves symbols in EXTERNAL_TEST from WORKSPACE_TEST
### Current Migration Status (as of 2025-12-07)
- ✅ Phase 1-2: Archive legacy, bootstrap lazy.nvim
- ✅ Phase 3: Core editing & LSP complete
- Settings, completion, LSP servers, Mason installed
- Native exrc + vim.lsp.config migration done
- Project-local `.nvim.lua` working
- ⏸️ Phase 4+: Navigation (Neo-tree, Telescope), Treesitter, UX plugins pending
## Integration Points
### External Dependencies
- **Neovim 0.11+**: Required for `vim.lsp.config` API
- **LSP Servers** (via Mason): lua_ls, ts_ls, html, cssls, jsonls, bashls, marksman, intelephense
- **PHP**: intelephense with `single_file_support = false`, uses `environment.includePaths` for external libs
### Cross-Component Communication
- LSP settings flow: `.nvim.lua``on_new_config``new_config.settings``workspace/didChangeConfiguration`
- Completion: cmp-nvim-lsp provides capabilities → lspconfig → LSP servers
## Common Issues
### lua_ls Won't Start
Mason-installed lua_ls may fail with missing `libbfd-2.38-system.so`. Install via system package manager instead.
### LSP Root Detection
If parent repo picked as root, create empty `.git` or `.nvimroot` marker in intended workspace root.
### Duplicate gd Results (Fixed)
Was caused by settings loading at wrong time; fixed by using `on_new_config` with actual `root_dir`.
## When Stuck
1. Check `MIGRATION_PLAN.md` for known issues and current phase
2. Review `AGENTS.md` for rules about what to avoid
3. Read `README.md` decisions log for context on past choices
4. Validate with test workspaces before modifying production config

3
.gitignore vendored
View File

@ -4,3 +4,6 @@ undodir/*
.vimtmp/*
view/*
tmpdir
WORKSPACE_TEST/
EXTERNAL_TEST/
WORKSPACE_SIMPLE/

170
AGENTS.md Normal file
View File

@ -0,0 +1,170 @@
# AGENTS: Neovim Config Migration
Scope: applies to the entire `~/.config/nvim` directory tree.
This repository is being migrated to a modern, minimal Neovim setup driven by Lua and lazy.nvim. Follow these rules when making changes.
## Goals
- Modern Lua-first config; avoid Vimscript unless explicitly requested.
- Keep it minimal, fast, and maintainable.
- Base plugin management on `lazy.nvim` with modular plugin specs.
- Support Telescope navigation, netrw for file browsing/preview, Oil.nvim for file operations, LSP, Treesitter, Copilot, and sane UX defaults.
- Native project-local configuration via `exrc` + `secure` (no external config plugins).
## Do Not Reintroduce
- Custom Vimscript tabline/statusline, foldtext, UI hacks.
- Legacy autocommands toggling cursorline/column per window.
- CoC or CoC-specific config.
- Neo-tree (skipped in favor of netrw for navigation).
- Providers for ruby/perl/node (disable unless required by a plugin).
- Auto-reload vimrc-on-write templates.
- `cursorcolumn` and old folding logic not related to UFO.
- neoconf plugin (incompatible with Neovim 0.11+, use native exrc instead).
- Motion plugins like leap.nvim or flash.nvim (not needed).
- Markdown rendering plugins (skipped entirely).
## Repository Structure (target)
```
~/.config/nvim/
├── init.lua -- entrypoint; bootstraps lazy.nvim and loads Lua modules
└── lua/
├── settings.lua -- non-plugin options
├── keymaps.lua -- non-plugin keymaps
├── autocmds.lua -- non-plugin autocommands
├── abbreviations.lua -- insert-mode abbreviations
├── netrw-config.lua -- netrw configuration
├── utils.lua -- helpers (only if needed)
└── plugins/ -- one file per plugin or domain
├── telescope.lua
├── treesitter.lua
├── cmp.lua
├── lsp.lua
├── copilot.lua
├── oil.lua
├── ufo.lua
├── gitsigns.lua
├── none-ls.lua
├── nvim-lint.lua
├── mason.lua
├── mason-lspconfig.lua
├── mason-tool-installer.lua
├── comment.lua
├── surround.lua
├── autopairs.lua
└── indent-blankline.lua
├── after/
│ ├── ftplugin/
│ │ └── php.lua -- PHP-specific settings (includeexpr for gf)
│ └── queries/ -- Custom Treesitter queries
│ ├── css/
│ │ └── highlights.scm
│ └── html/
│ └── highlights.scm
├── templates/
│ └── template.sh -- Shell script template
└── legacy/ -- Archived Vimscript config (reference only)
```
## Coding Conventions
- Use Lua APIs: `vim.opt`, `vim.api.nvim_create_autocmd`, `vim.keymap.set`.
- No inline Vimscript or `vim.cmd` blocks unless strictly necessary.
- Keep plugin configuration self-contained in its plugin spec file.
- Prefer small, readable modules and minimal configuration over heavy customization.
- Keymaps: use `vim.keymap.set` with `{ silent = true, noremap = true }` defaults unless otherwise required.
- Autocommands: group via `vim.api.nvim_create_augroup` and create specific, narrowly scoped autocmds.
- Avoid global state; return tables from modules and plugin specs.
## Plugin Management (lazy.nvim)
- Each plugin lives in `lua/plugins/<name>.lua` and returns a spec table.
- Use `opts = {}` for default options and `config = function(_, opts) ... end` for setup.
- Do not install any plugin not listed without explicit user confirmation (proposal and rationale are welcome).
- Rejected: `folke/neoconf.nvim` (incompatible with Neovim 0.11+ vim.lsp.config API).
## Required Plugin Categories
- Core: `nvim-lspconfig`, `nvim-cmp`, `cmp-nvim-lsp`, `cmp-buffer`, `cmp-path`, `LuaSnip`.
- Navigation: `telescope.nvim` + `telescope-fzf-native.nvim`, `oil.nvim`.
- Treesitter: `nvim-treesitter`, `nvim-treesitter-textobjects`, `nvim-ts-autotag`.
- UX/Editing: `Comment.nvim`, `nvim-surround`, `nvim-autopairs`, `indent-blankline.nvim`, `nvim-ufo`, `undotree`.
- Git: `gitsigns.nvim`.
- Copilot: `copilot.lua`, `copilot-cmp`.
- Formatting/Linting: `none-ls.nvim`, `nvim-lint`.
- LSP Management: `mason.nvim`, `mason-lspconfig.nvim`, `mason-tool-installer.nvim`.
## Workflow Requirements to Preserve
- Netrw for visual context and project structure browsing (tree view, preview splits).
- Telescope for fuzzy finding (files, grep, buffers, LSP symbols).
- Oil.nvim for file manipulation (handles buffer sync on rename/move/delete).
- LSP for navigation (gd, gr, K, etc.).
- Heavy HTML/PHP/JS/Markdown usage (WordPress plugin dev) — prioritize these languages in LSP/Treesitter.
- Format-on-save with toggle capability.
- Project-local configuration via `.nvim.lua` files.
## Behaviours to Keep (modernized)
- Abbreviations: `adn→and`, `waht→what`, `tehn→then`, `functin→function`, `positin→position`.
- Templates: auto-populate `.sh` from template.
- Whitespace highlighting (use modern alternatives, e.g., `listchars`, plugins if needed).
- Persistent folds (prefer `nvim-ufo`).
- Spell & text: `spelllang=en_gb`, custom `listchars`, `showbreak`.
- Keyword characters: `iskeyword+=$` (for PHP/shell variables), `iskeyword+=-` (for CSS/HTML/config files).
## Current Status (Phase 10 Complete)
- ✅ Phase 1-2: Archive legacy, bootstrap lazy.nvim
- ✅ Phase 3: Core editing & LSP (native exrc + vim.lsp.config migration complete)
- ✅ Phase 4: Navigation (Telescope, netrw, Oil.nvim)
- ✅ Phase 5: Treesitter (parsers, textobjects, autotag)
- ✅ Phase 6: UX/Editing (Comment, surround, autopairs, indent guides, UFO, undotree)
- ✅ Phase 7: Git integration (Gitsigns)
- ✅ Phase 8: Copilot integration (copilot.lua + copilot-cmp)
- ✅ Phase 9: Formatting & Linting (none-ls, nvim-lint, Mason tool installer)
- ✅ Phase 10: Migrate kept behaviors (abbreviations, templates, custom Treesitter queries)
- ⏸️ Phase 11: Cleanup & validation (pending)
## Migration Notes
- Do not edit legacy Vimscript files except to extract settings to Lua. Keep them intact until migration completes.
- Introduce `init.lua` and bootstrap `lazy.nvim` before adding plugins.
- Disable unnecessary providers early: `vim.g.loaded_ruby_provider = 0`, etc.
- Keep startup fast; avoid unnecessary autoloading or heavy defaults.
- When cleaning, archive existing files into a `legacy/` folder within this config instead of deleting. Maintain a brief index if helpful.
## Validation
- Ensure Neovim starts without errors and with minimal startup time.
- Verify Telescope navigation, netrw browsing, Oil.nvim file operations, LSP basics, and completion.
- Keep plugin count tight; remove anything unused.
## Key Decisions & Architecture
### LSP Configuration
- **Modern API (Neovim 0.11+)**: Uses `vim.lsp.config()` + `vim.lsp.enable()`, NOT `require('lspconfig')[server].setup()`
- **Project-local config**: Native `exrc` + `secure` (no neoconf - incompatible with 0.11+)
- **Config format**: `.nvim.lua` files return `{ lsp = { [server_name] = { settings = {...} } } }`
- **Security**: `secure` mode prompts user to trust `.nvim.lua` files (one-time per file hash)
- **Settings loading**: `on_new_config` hook loads from actual `root_dir` (not cwd)
- **PHP**: intelephense with `single_file_support = false`, uses `environment.includePaths` for external libs
### Navigation Strategy
- **netrw**: Visual context, tree view, preview splits (horizontal 50/50 below)
- **Telescope**: Fuzzy finding (files, grep, buffers, LSP symbols)
- **Oil.nvim**: File manipulation (handles buffer sync on rename/move/delete)
- **PHP gf enhancement**: Custom `includeexpr` in `after/ftplugin/php.lua` for WordPress/PHP patterns
### Formatting & Linting
- **Formatters**: prettier, phpcbf, stylua, black (project-local → Mason → global)
- **Linters**: eslint_d, phpcs, markdownlint, ruff (via nvim-lint)
- **Format-on-save**: Enabled by default, toggle with `<leader>lt`
- **Philosophy**: Formatters are source of truth; Neovim settings match formatter rules per filetype
### Treesitter
- **Parsers**: lua, vim, vimdoc, php, html, javascript, typescript, tsx, css, scss, json, markdown, bash, regex
- **Features**: Incremental selection (CR/BS), textobjects (functions, classes, parameters), autotag
- **Custom queries**: `after/queries/css/highlights.scm`, `after/queries/html/highlights.scm`
## Process
- Before large changes, update the task plan via the CLI `update_plan` tool.
- Keep the live checklist in `MIGRATION_PLAN.md:1` up to date and in sync with changes.
- After any config or plugin change, immediately update `MIGRATION_PLAN.md` (check off items, add notes, or adjust next steps).
- After any change or decision, also update `README.md:1` (decisions log and design docs).
- At the start of each phase, confirm scope and priorities for that phase.
- Execute phases via subphases (`N.x`), where each bullet under a phase is its own implement-and-test step (e.g., Phase 3.1, 3.2, 3.3, 3.4).
- Record decisions and rationale in `README.md:1` as theyre made.
- Keep PR-sized patches; avoid broad unrelated edits.
- Document non-obvious choices in commit messages or short comments near the code that needs it.

505
MIGRATION_PLAN.md Normal file
View File

@ -0,0 +1,505 @@
# Neovim Migration Checklist
Source of truth for the step-by-step rebuild. Keep this concise and up to date. See details in `neovim-migration-guide.md`.
## Phase 0 — Ground Rules
- [x] Create AGENTS.md with rules
## Phase 1 — Clean & Archive Legacy Config
## Phase 1.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
## Phase 1.2 — Inventory legacy files
- [x] Inventory existing Vimscript, plugin files, and directories
## Phase 1.3 — Create archive location
- [x] Create `legacy/` archive folder within this config
## Phase 1.4 — Move legacy files into archive
- [x] Move legacy init files and plugin directories into `legacy/` (do not delete)
## Phase 1.5 — Document archived contents
- [x] Optionally add `legacy/README.md` noting what was archived
## Phase 1.6 — Preserve selected directories
- [x] Keep `undodir`, `spell`, `view`, `UltiSnips`, `templates` as-is for now (review later)
## Phase 2 — Bootstrap
## Phase 2.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
## Phase 2.2 — Scaffold Lua config skeleton
- [x] Scaffold Lua config skeleton (`init.lua`, `lua/settings.lua`, `lua/keymaps.lua`, `lua/autocmds.lua`, `lua/utils.lua`, `lua/plugins/`)
## Phase 2.3 — Bootstrap lazy.nvim
- [x] Bootstrap `lazy.nvim` plugin manager
## Phase 2.4 — Disable unused providers
- [x] Disable unused providers (ruby, perl, node)
## Phase 2.5 — Ensure lazy boots without specs
- [x] Ensure lazy boots without specs (add empty `lua/plugins/init.lua`)
## Phase 3 — Core Editing & LSP
## Phase 3.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: PHP LSP = `intelephense`
- [x] Decision: Enable Markdown LSP = `marksman`
- [x] Decision: Use legacy `listchars` and `showbreak` values
- [x] Decision: Support perproject config for `intelephense.includePaths`
- [x] Decision: No direnv fallback for local config
## Phase 3.2 — Non-plugin settings to Lua
- [x] Port non-plugin settings to Lua (options, listchars, showbreak, spelllang=en_gb)
## Phase 3.3 — Core completion stack
- [x] Add core completion stack: `nvim-cmp`, `cmp-nvim-lsp`, `cmp-buffer`, `cmp-path`, `LuaSnip`
## Phase 3.4 — Projectlocal configuration (native exrc)
- [x] Confirm scope and priorities for this subphase
- [x] Decision: Use native `exrc` + `secure` instead of neoconf (neoconf incompatible with Neovim 0.11+ vim.lsp.config API)
- [x] Enable `exrc` and `secure` in settings.lua
- [x] Implement `.nvim.lua` loader in LSP config using `on_new_config` hook
- [x] Wire `intelephense.environment.includePaths` via `.nvim.lua`
- [x] Create validation workspaces: `WORKSPACE_TEST/` and `EXTERNAL_TEST/` with sample PHP files
- [x] Migrate to `vim.lsp.config()` and `vim.lsp.enable()` (Neovim 0.11+ native API)
- [x] Verify project settings load correctly from actual root_dir
- [x] Clean up debug notifications and temporary code
## Phase 3.7 — Clean LSP config
- [x] Remove debug/helper logic from LSP config
- [x] Migrate from deprecated `require('lspconfig')[server].setup()` to `vim.lsp.config()` + `vim.lsp.enable()`
- [x] Use `on_new_config` hook for project-local settings loading (loads from actual root_dir, not cwd)
## Phase 3.8 — Validate project-local LSP settings
- [x] Create test workspaces with `.nvim.lua` files
- [x] Validate settings load from actual root_dir via `on_new_config` hook
- [x] Verify `gd` works for external library references via `intelephense.environment.includePaths`
- [x] Clean up debug code and notifications
## Phase 3.9 — Native exrc + vim.lsp.config migration (RESOLVED)
- [x] Discovered neoconf incompatible with Neovim 0.11+ (GitHub issue #116, unresolved since May 2024)
- [x] Migrated to native `exrc` + `secure` approach (zero dependencies, aligned with minimal philosophy)
- [x] Implemented `.nvim.lua` loader using `on_new_config` hook (loads from actual root_dir)
- [x] Migrated from deprecated `require('lspconfig')` framework to `vim.lsp.config()` + `vim.lsp.enable()`
- [x] Root detection handled by nvim-lspconfig's native configs (no custom root_dir needed)
- [x] Validated `gd` works for external library symbols via `intelephense.environment.includePaths`
- [x] Settings schema: `.nvim.lua` returns `{ lsp = { [server_name] = { settings = {...} } } }`
- [x] Security: `secure` mode prompts user to trust `.nvim.lua` files before execution
- [x] Kept `single_file_support = false` for `intelephense`
- [x] Fixed duplicate `gd` results issue
## Phase 3.5 — LSP minimal defaults
- [x] Add `nvim-lspconfig` with minimal defaults (no over-configuration)
- [x] Add minimal LSP on-attach keymaps (gd, gr, K, gD, gI)
- [x] Add global LSP keymaps with fallback in `lua/keymaps.lua`
- [x] Intelephense: set `single_file_support=false`, root detection via nvim-lspconfig defaults
- [x] Project settings loaded via `on_new_config` hook from `.nvim.lua` files
## Phase 3.6 — LSP server management (Mason)
- [x] Confirm scope and priorities for this subphase
- [x] Add `williamboman/mason.nvim` and `williamboman/mason-lspconfig.nvim`
- [x] Ensure servers installed: `lua_ls`, `tsserver`, `html`, `cssls`, `jsonls`, `bashls`, `marksman`, `intelephense`
- [x] Keep our custom per-server setup; use Mason only for installation
## Phase 4 — Navigation
## Phase 4.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Skip Neo-tree in favor of netrw for navigation/visual context
- [x] Decision: Use netrw for project structure visualization and file preview
- [x] Decision: Telescope as primary "find file" tool
- [x] Decision: Add Oil.nvim for file manipulation (handles buffer sync on rename/move/delete)
- [x] Note: Oil.nvim is for evaluation; alternative is mini.files if too heavy
## Phase 4.2 — Configure netrw
- [x] Configure netrw with tree view, preview split, and basic settings (no banner, sensible defaults)
- [x] Created `lua/netrw-config.lua` with settings: tree view, horizontal preview split below, 50/50 split, human-readable sizes
- [x] Add netrw keymaps: `<leader>te` (new tab at current file's directory), `<leader>tE` (new tab at project root)
- [x] Decision: No `<leader>e` or `<leader>v` keymaps - use `:Ex`, `:Vex` directly when needed
- [x] Preview behavior: Enter opens file in netrw window, `p` opens 50/50 horizontal split below
## Phase 4.2.1 — PHP gf enhancement
- [x] Add PHP `includeexpr` for intelligent `gf` behavior (handles `__DIR__`, `__FILE__`, `dirname(__FILE__)` patterns)
- [x] Created `after/ftplugin/php.lua` with path resolution for WordPress/PHP patterns
- [x] Tested and validated with test-gf.php
## Phase 4.3 — Telescope setup
- [x] Add `telescope.nvim` + `telescope-fzf-native.nvim` for fuzzy finding
- [x] Configure basic pickers: `find_files`, `live_grep`, `buffers`, `help_tags`, `oldfiles`, `current_buffer_fuzzy_find`
- [x] Add LSP pickers: `lsp_document_symbols`, `lsp_workspace_symbols`
- [x] Keymaps configured:
- `<leader>ff` - Find files
- `<leader>fg` - Live grep (search text)
- `<leader>fb` - Find buffers (with `<C-d>` to delete)
- `<leader>fh` - Find help
- `<leader>fr` - Recent files
- `<leader>/` - Search current buffer
- `<leader>fs` - Document symbols (LSP)
- `<leader>fS` - Workspace symbols (LSP)
- [x] Minimal UI: dropdown theme for files/buffers, no previewer for quick selection
## Phase 4.4 — Oil.nvim for file manipulation
- [x] Add `stevearc/oil.nvim` for filesystem operations (rename, create, delete, copy, move)
- [x] Configure to handle buffer name sync on file operations
- [x] Keep minimal - use only when shell operations would cause buffer issues
- [x] Keymaps configured:
- `<leader>fo` - Open Oil file browser (regular buffer)
- `<leader>fO` - Open Oil in floating window (with floating previews)
- `<C-p>` in Oil - Preview files (vertical split to right for regular, floating window for float mode)
- [x] Preview splits open to the right via `vertical = true` and `split = 'belowright'`
- [x] Floating window preview direction: `preview_split = "right"`
- [x] Note: Evaluate practicality; can switch to `mini.files` if preferred
## Phase 5 — Treesitter
## Phase 5.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Focus on languages: PHP, HTML, JavaScript, TypeScript, CSS, Markdown, Lua, Bash, JSON
- [x] Decision: Enable syntax highlighting and incremental selection (CR to expand, BS to shrink)
- [x] Decision: Enable textobjects for functions, classes, parameters, conditionals, loops
- [x] Decision: Enable autotag for HTML/PHP/JS/React files
- [x] Decision: Disable indent (experimental) to start; can enable per-filetype if stable
## Phase 5.2 — Base Treesitter
- [x] Add `nvim-treesitter` with incremental selection, highlighting
- [x] Configure parsers: lua, vim, vimdoc, php, html, javascript, typescript, tsx, css, scss, json, markdown, markdown_inline, bash, regex
- [x] Enable auto-install for missing parsers
- [x] Incremental selection keymaps: CR (init/expand), S-CR (scope expand), BS (shrink)
- [x] Disable for large files (>100KB) to maintain performance
## Phase 5.3 — Treesitter textobjects
- [x] Add `nvim-treesitter-textobjects`
- [x] Select keymaps: `af`/`if` (function), `ac`/`ic` (class), `aa`/`ia` (parameter), `ai`/`ii` (conditional), `al`/`il` (loop), `a/` (comment)
- [x] Move keymaps: `]f`/`[f` (next/prev function start), `]F`/`[F` (function end), similar for classes and parameters
- [x] Swap keymaps: `<leader>a`/`<leader>A` (swap parameter with next/prev)
## Phase 5.4 — Treesitter autotag
- [x] Add `nvim-ts-autotag`
- [x] Enable auto-close, auto-rename, and close-on-slash for HTML/PHP/JS/React/TS/Vue files
## Phase 6 — UX / Editing
## Phase 6.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: No cursorcolumn (as per AGENTS.md)
- [x] Decision: No auto-window toggling behavior (keep settings static)
- [x] Decision: No motion plugin (skip leap/flash)
- [x] Decision: Move undotree to separate Phase 6.8
- [x] UX settings to add: signcolumn, cursorline, colorcolumn
## Phase 6.2 — Core UX settings
- [x] Add signcolumn=yes (always show gutter for LSP/git)
- [x] Add cursorline (highlight current line)
- [x] Add colorcolumn=80,120 (visual guides)
- [x] No cursorcolumn (excluded as per AGENTS.md)
- [x] No per-window autocommands (keep simple)
## Phase 6.3 — Comment.nvim
- [x] Add `numToStr/Comment.nvim`
- [x] Configure for gcc/gc commenting
- [x] Add keymaps if needed
## Phase 6.4 — Surround
- [x] Add `kylechui/nvim-surround`
- [x] Minimal config with default keymaps (ys, ds, cs)
## Phase 6.5 — Autopairs
- [x] Add `windwp/nvim-autopairs`
- [x] Integrate with nvim-cmp
## Phase 6.6 — Indent guides
- [x] Add `lukas-reineke/indent-blankline.nvim`
- [x] Configure scope highlighting
## Phase 6.7 — Folding (UFO)
- [x] Add `kevinhwang91/nvim-ufo` for folding
- [x] Configure with Treesitter and LSP providers
- [x] Add fold keymaps (za, zR, zM, etc.)
## Phase 6.8 — Undotree
- [x] Add `mbbill/undotree`
- [x] Add keymap to toggle undotree
- [x] Configure minimal settings
## Phase 7 — Git Integration
## Phase 7.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Gitsigns with minimal config - signs in gutter, hunk navigation/actions only
- [x] Decision: Skip markdown rendering plugins entirely
## Phase 7.2 — Gitsigns
- [x] Add `lewis6991/gitsigns.nvim`
- [x] Configure signs in gutter (add, change, delete, topdelete, changedelete)
- [x] Add hunk navigation keymaps (]h/[h for next/prev hunk)
- [x] Add hunk action keymaps (stage, reset, preview)
- [x] Keep minimal - no inline blame, no advanced features
## Phase 8 — Copilot
## Phase 8.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Integrate Copilot into nvim-cmp as completion source
- [x] Decision: Auto-trigger suggestions as you type
- [x] Decision: No specific Copilot keymaps needed (use existing cmp keymaps)
- [x] Decision: Enable for all filetypes
- [x] Decision: Copilot suggestions appear before LSP suggestions in completion menu
- [x] Node.js v22.21.1 upgraded and confirmed working
## Phase 8.2 — Copilot setup
- [x] Add `zbirenbaum/copilot.lua` + `zbirenbaum/copilot-cmp`
- [x] Configure copilot.lua with auto-trigger and all filetypes
- [x] Add copilot-cmp as source to nvim-cmp
- [x] Set copilot-cmp priority higher than LSP in completion menu
- [x] Note: Copilot initializes on first InsertEnter; enter/exit insert mode once before using `:Copilot auth`
## Phase 9 — Formatting & Linting
## Phase 9.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Formatters - prettier (JS/TS/CSS/JSON/MD/HTML), phpcbf (PHP), stylua (Lua), black (Python)
- [x] Decision: Linters - eslint (JS/TS), phpcs (PHP), markdownlint (Markdown), ruff (Python)
- [x] Decision: Project-local executables preferred, fallback to global (node_modules/.bin/, vendor/bin/)
- [x] Decision: phpcs/phpcbf already installed globally with WordPress coding standards - no installation needed
- [x] Decision: Format-on-save enabled by default with toggle capability
- [x] Decision: Manual format keymaps: `<leader>lf` (normal), `<leader>lf` (visual range)
- [x] Decision: Respect project config files (.prettierrc, phpcs.xml, .eslintrc, pyproject.toml, etc.)
- [x] Strategy: Helper function detects project-local executables first, then global
- [x] WordPress: phpcs.xml in project root or --standard=WordPress flag for WordPress projects
- [x] Philosophy: Formatters are authoritative source of truth; Neovim settings should match formatter rules per filetype
- [x] Note: Phase 9.4 will align Neovim editor settings (tabstop, shiftwidth, expandtab) with formatter configurations
## Phase 9.2 — none-ls setup with project-aware executables
- [x] Add `nvimtools/none-ls.nvim`
- [x] Create helper function to detect project-local executables (node_modules/.bin/, vendor/bin/, Mason bin)
- [x] Configure formatters:
- [x] prettier (project-local first, then Mason, then global)
- [x] phpcbf (project-local first, then global system install - already available)
- [x] stylua (Mason installed)
- [x] Add `mfussenegger/nvim-lint` for linting (none-ls removed most linters from builtins)
- [x] Configure linters via nvim-lint:
- [x] eslint_d (project-local first, then Mason, then global - daemon version for speed)
- [x] phpcs (project-local first, then global system install - already available)
- [x] markdownlint (Mason installed)
- [x] Add format-on-save autocommand with toggle capability (`<leader>lt` to toggle)
- [x] Add manual format keymaps: `<leader>lf` (buffer), `<leader>lf` (visual range)
- [x] Ensure WordPress coding standards work via phpcs.xml or --standard flag
- [x] Search order: project node_modules/.bin/ → project vendor/bin/ → Mason bin → system PATH
- [x] Note: Linting runs on BufEnter, BufWritePost, InsertLeave events
## Phase 9.3 — Mason formatter/linter installation
- [x] Add `WhoIsSethDaniel/mason-tool-installer.nvim` for automated installation
- [x] Install via Mason: prettier, eslint_d, markdownlint, stylua, black, ruff
- [x] Note: phpcs/phpcbf already installed globally, skip Mason installation
- [x] Verify all tools available: Tools installed to ~/.local/share/nvim/mason/bin/
## Phase 9.4 — Align Neovim settings with formatter rules
- [x] Configure per-filetype settings to match formatter defaults
- [x] PHP: tabs, 2-width display (WordPress standards)
- [x] JS/TS/CSS/JSON/HTML: spaces, 2-width (Prettier defaults)
- [x] Lua: spaces, 2-width (common Neovim convention)
- [x] Markdown: spaces, 2-width (Prettier defaults)
- [x] Python: spaces, 4-width (Black/PEP 8 defaults)
- [x] Use autocmds in lua/autocmds.lua for filetype-specific tabstop, shiftwidth, expandtab
- [x] Set global defaults: 4-width, spaces (reasonable baseline)
- [x] Goal: Manual editing feels natural and matches what formatter will produce on save
- [x] Note: All settings kept explicit per-filetype for clarity and maintainability
## Phase 10 — Migrate Kept Behaviours
## Phase 10.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Port abbreviations to Lua via vim.cmd.iabbrev
- [x] Decision: Port shell template auto-loading via autocmd + BufReadPost
- [x] Decision: Whitespace highlighting already handled via listchars (Phase 3.2)
- [x] Decision: Skip persistent folds (UFO handles folding, no explicit persistence needed)
## Phase 10.2 — Abbreviations
- [x] Abbreviations: `adn→and`, `waht→what`, `tehn→then`, `functin→function`, `positin→position`
- [x] Created dedicated `lua/abbreviations.lua` for modularity and easier maintenance
## Phase 10.3 — Templates
- [x] Templates: auto-populate new `.sh` from template
- [x] Added BufNewFile autocmd for *.sh in lua/autocmds.lua
## Phase 10.4 — Whitespace highlighting
- [x] Whitespace highlighting (modern approach)
- [x] Note: Already handled via listchars in Phase 3.2 (settings.lua)
## Phase 10.5 — Persistent folds
- [x] Persistent folds (via UFO) -- no need, this is no longer required.
- [x] Note: UFO handles folding; no explicit persistence mechanism needed
## Phase 11 — Colorscheme: Modern Paper Tonic
## Phase 11.1 — Confirm scope and priorities
- [x] Confirm scope and priorities for this phase
- [x] Decision: Create modern Paper Tonic fork from scratch
- [x] Decision: Name = "paper-tonic-modern"
- [x] Decision: Location = inside nvim config initially, move to repo later
- [x] Decision: Structure = modular Lua colorscheme (colors.lua, groups/*.lua)
- [x] Phased approach:
- Phase 11.2-11.4: Extract palette and base groups
- Phase 11.5-11.6: General TreeSitter highlights (modern @* groups)
- Phase 11.7: Semantic highlighting (custom CSS/HTML captures)
- Phase 11.8: Plugin support (LSP, Telescope, Gitsigns, etc.)
## Phase 11.2 — Extract Paper Tonic color palette
- [x] Create `lua/paper-tonic-modern/colors.lua`
- [x] Extract all `c_*` color variables from Paper Tonic
- [x] Document what each color represents (foreground, background, accent colors)
- [x] Convert to modern format (keep hex, 256-color, ANSI mappings)
## Phase 11.3 — Create colorscheme structure
- [x] Create directory structure:
- `colors/paper-tonic-modern.lua` (entry point)
- `lua/paper-tonic-modern/init.lua` (main logic)
- `lua/paper-tonic-modern/colors.lua` (palette)
- `lua/paper-tonic-modern/groups/` (highlight group definitions)
- [x] Create helper function for setting highlights
- [x] Set up colorscheme loading mechanism
## Phase 11.4 — Base vim highlight groups
- [x] Create `lua/paper-tonic-modern/groups/editor.lua`
- [x] Map Paper Tonic colors to base groups: Normal, Comment, LineNr, CursorLine, etc.
- [x] Create `lua/paper-tonic-modern/groups/syntax.lua`
- [x] Map to syntax groups: Function, String, Keyword, Identifier, etc.
- [x] Test with simple Lua file to verify base colors work
## Phase 11.5 — Modern TreeSitter highlight groups
- [x] Create `lua/paper-tonic-modern/groups/treesitter.lua`
- [x] Map modern `@*` groups to Paper Tonic colors:
- Core: @variable, @function, @keyword, @string, @number, @boolean, @comment
- Types: @type, @property, @field, @parameter
- Operators: @operator, @punctuation.delimiter, @punctuation.bracket
- Language constructs: @keyword.function, @keyword.return, @keyword.conditional
- [x] Use `:help treesitter-highlight-groups` as reference
- [x] Test with multiple languages: Lua, PHP, JavaScript, HTML, CSS
## Phase 11.6 — Language-specific TreeSitter groups
- [x] Add language-specific overrides (e.g., @variable.php, @tag.html)
- [x] Ensure HTML tags, CSS selectors, PHP variables have appropriate colors
- [x] Test across primary languages (HTML, PHP, JS, CSS, Markdown)
- [x] Added comprehensive language-specific groups:
- CSS/SCSS: properties, variables, functions (green c2 tones)
- HTML: tags, attributes, delimiters (blue c3)
- PHP: variables, functions, methods, built-ins (primary brownish-red)
- JavaScript/TypeScript: variables, functions, properties, JSX tags (primary + blue for JSX)
- Lua: variables, functions, built-ins (primary)
- Markdown: headings, links, code blocks (primary for structure)
- JSON: properties, strings, numbers (neutral)
- Bash: variables, functions, built-ins (primary)
## Phase 11.7 — Semantic highlighting (custom captures)
- [x] Create `lua/paper-tonic-modern/groups/semantic.lua`
- [x] Define your custom semantic captures:
- @CssClassName (for CSS .class and HTML class="" - same color)
- @CssIdentifier (for CSS #id and HTML id="" - same color)
- @DataAttribute, @DataAttributeValue (HTML data-* attributes)
- @cssPseudoClass, @cssNestingSelector, @CssUniversalSelector (CSS-specific)
- [x] Verify cross-language consistency: class names in HTML match CSS
- [x] Implemented semantic highlights:
- CSS: @CssClassName (green c2), @CssIdentifier (strong green c2_strong), @cssPseudoClass (weak green c2_weak)
- CSS: @cssNestingSelector (strong green), @CssUniversalSelector (SpecialChar)
- CSS: @CssProp (primary_weak), @CssPropertyValue (bold), @CssUnit (Delimiter)
- HTML: @ClassNameAttribute, @IdAttribute, @DataAttribute (all fg_weak for attribute names)
- HTML: @DataAttributeValue (Function)
- Cross-language: class values and #id values in HTML use same colors as CSS selectors
- [ ] Test with existing custom queries (after/queries/css/highlights.scm, after/queries/html/highlights.scm)
## Phase 11.8 — Plugin highlight groups
- [x] Create `lua/paper-tonic-modern/groups/lsp.lua`
- [x] Define LSP diagnostics: DiagnosticError, DiagnosticWarn, DiagnosticHint, DiagnosticInfo
- [x] Define LSP UI: LspReferenceText, LspReferenceRead, LspReferenceWrite
- [x] Create `lua/paper-tonic-modern/groups/plugins.lua`
- [x] Add Telescope highlights (TelescopeNormal, TelescopeBorder, TelescopeSelection)
- [x] Add Gitsigns highlights (GitSignsAdd, GitSignsChange, GitSignsDelete)
- [x] Add nvim-cmp highlights (CmpItemKind*, CmpItemMenu, etc.)
- [x] Add Oil.nvim highlights if needed
**Notes**:
- LSP diagnostics use red (error), orange (warn), blue (info), green (hint)
- LSP references use cyan backgrounds with varying intensity (text/read/write)
- LSP semantic tokens link to TreeSitter groups for consistency
- Telescope uses neutral colors with primary accent for matching and selection
- Gitsigns uses status colors: green (add), blue (change), red (delete)
- nvim-cmp uses primary tones for kinds, bold for matching text
- Oil.nvim uses bold for directories, status colors for permissions and operations
- indent-blankline and ufo use subtle grays for non-intrusive UI
## Phase 11.9 — Update plugin configuration
- [x] Update `lua/plugins/colorscheme.lua` to use paper-tonic-modern
- [x] Remove old Paper Tonic reference
- [x] Remove colorscheme-overrides.lua (no longer needed)
- [x] Test full config reload
**Notes**:
- `lua/plugins/colorscheme.lua` already updated to load `paper-tonic-modern`
- Old `paper-tonic/` directory moved to `legacy/paper-tonic-original/` (archived)
- No `colorscheme-overrides.lua` existed (not needed with modern implementation)
- Full config reload tested: Normal ✓, DiagnosticError ✓, TelescopeNormal ✓, GitSignsAdd ✓
- Colorscheme loads correctly: `vim.g.colors_name = 'paper-tonic-modern'`
## Phase 11.10 — Validation and polish
- [ ] Test all primary languages (Lua, PHP, HTML, CSS, JS, Markdown)
- [ ] Verify semantic consistency (CSS classes in HTML match CSS files)
- [ ] Check plugin UI colors (Telescope, Gitsigns, nvim-cmp)
- [ ] Verify LSP diagnostics are visible and distinct
- [ ] Document color scheme in README
## Phase 11.11 — Extract to separate repo (later)
- [ ] Move to `~/projects/paper-tonic-modern/`
- [ ] Update plugin config to point to new location
- [ ] Add proper README, LICENSE, screenshots
- [ ] Consider publishing to GitHub
## Phase 12 — Cleanup & Validation
## Phase 12.1 — Confirm scope and priorities
- [ ] Confirm scope and priorities for this phase
## Phase 12.2 — Retire legacy files
- [ ] Retire legacy Vimscript files (keep for reference until verified)
## Phase 12.3 — Startup performance
- [ ] Validate startup performance (no errors, fast launch)
## Phase 12.4 — Navigation validation
- [ ] Validate Telescope navigation + LSP jumps
- [ ] Validate netrw browsing and preview splits
- [ ] Validate Oil.nvim file operations
## Phase 12.5 — Language tooling validation
- [ ] Validate HTML/PHP/JS/Markdown tooling
- [ ] Verify LSP (gd, gr, K, diagnostics)
- [ ] Verify formatting (prettier, phpcbf, stylua)
- [ ] Verify linting (eslint_d, phpcs, markdownlint)
## Phase 12.6 — Final polish
- [ ] Review all keymaps and ensure they're documented
- [ ] Update README.md with final architecture and usage
- [ ] Clean up any remaining debug code or temporary comments
---
Notes:
- Keep plugin specs minimal; configure in their own `lua/plugins/*.lua` files.
- Avoid adding plugins not listed in the guide unless explicitly requested.
- Prefer simple defaults; only add settings that clearly improve workflow.
- Plugin approval policy: unlisted plugins may be proposed, but must be explicitly confirmed before installation.
Known Issues / Follow-ups:
- lua-language-server (lua_ls) from Mason failed to start due to missing shared library `libbfd-2.38-system.so`. **RESOLVED**: Installed lua-language-server via system package manager (pacman) instead of Mason. Removed `lua_ls` from Mason's ensure_installed list in `lua/plugins/mason-lspconfig.lua`.
- LSP root detection: In some cases, the parent repository is picked as the root (e.g., when a workspace lives inside another repo). Workaround: create an empty `.git` directory (or a marker like `.nvimroot`) in the intended workspace root to pin the project root for LSPs.
Decisions & Changes:
- **Neoconf dropped**: folke/neoconf.nvim incompatible with Neovim 0.11+ vim.lsp.config API (GitHub issue #116, open since May 2024, no resolution). Migrated to native `exrc` + `secure` approach.
- **vim.lsp.config migration**: Migrated from deprecated `require('lspconfig')[server].setup()` to `vim.lsp.config()` + `vim.lsp.enable()` (Neovim 0.11+ native API).
- **Project config format**: `.nvim.lua` files return `{ lsp = { [server_name] = { settings = {...} } } }`.
- **Security model**: `secure` mode prompts user to trust `.nvim.lua` files before execution (one-time per file hash).
- **Settings loading**: `on_new_config` hook loads project settings from actual `root_dir` (not cwd), ensuring correct behavior across different workspace structures.
- **Phase 4 Navigation Strategy**: Skipped Neo-tree in favor of built-in netrw for visual context and project structure browsing. Telescope for fuzzy finding. Oil.nvim for file manipulation (evaluation phase; alternative is mini.files). Rationale: User needs visual context and preview, not per-tab roots or complex tree features. File manipulation primarily done in shell, but Oil.nvim handles buffer sync issues when renaming/moving files.

260
README.md Normal file
View File

@ -0,0 +1,260 @@
# Neovim Rebuild — Decisions & Reference
Authoritative notes for the Neovim migration. Use this alongside `MIGRATION_PLAN.md` and `neovim-migration-guide.md`.
- Migration plan: MIGRATION_PLAN.md
- Guide and requirements: neovim-migration-guide.md
## Decisions Log
Record every decision here with a short rationale. Append new entries; do not rewrite history.
- 2025-12-06: PHP LSP = `intelephense` (good PHP ecosystem support; integrates includePaths).
- 2025-12-06: Enable Markdown LSP = `marksman` (lightweight, good MD features).
- 2025-12-06: Use legacy `listchars` and `showbreak` values (preserve muscle memory).
- 2025-12-06: No direnv fallback for local config (keep setup simple and repo-driven).
- 2025-12-06: Project-local config = layered JSON `.nvim.json` + `.nvim.local.json` with `.nvimroot` as workspace boundary marker (multi-repo friendly).
- 2025-12-06: Switch to `folke/neoconf.nvim` for project-local configuration (supersedes custom layered JSON loader); use `.neoconf.json` at workspace root.
- 2025-12-06: Use `mason.nvim` + `mason-lspconfig.nvim` to install/manage LSP servers; keep custom lspconfig setup; include `.neoconf.json` in root detection.
- For PHP validation inside this repo: we require `.neoconf.json` to attach `intelephense` to avoid the repos `.git` being chosen as the LSP root.
- 2025-12-06: Plugin approval policy — other plugins are allowed, but do not install any plugin not listed without explicit confirmation.
- 2025-12-07: **CRITICAL REGRESSION FIX**: Neovim 0.11+ does NOT support `on_new_config` callback in `vim.lsp.config()`. Project-local settings (`.nvim.lua`) must be loaded via `LspAttach` autocmd instead. The `on_new_config` hook was silently ignored, causing empty settings and breaking goto-definition for external includes. Solution: Use `LspAttach` to load project settings, merge into `client.settings`, and send `workspace/didChangeConfiguration` notification.
- 2025-12-07: Native `exrc` + `.nvim.lua` finalized as project-local config approach (replaces neoconf, which is incompatible with Neovim 0.11+ native LSP API). Security via `vim.opt.secure = true`.
- 2025-12-07: Navigation Phase 4 decisions:
- Skip Neo-tree in favor of netrw for project visualization
- Use Telescope as primary "find file" tool with fuzzy finding
- Add Oil.nvim for file manipulation (rename/move/delete with buffer sync)
- netrw for tree view and preview splits; Oil for operations that would break buffer names
- PHP `gf` enhancement via `includeexpr` for WordPress/PHP path resolution
- 2025-12-07: Treesitter Phase 5 decisions:
- Focus on core languages: PHP, HTML, JavaScript, TypeScript, CSS, Markdown, Lua, Bash, JSON
- Enable syntax highlighting with performance safeguard (disable for files >100KB)
- Incremental selection: CR to expand, BS to shrink, S-CR for scope expansion
- Textobjects for functions (`af`/`if`), classes (`ac`/`ic`), parameters (`aa`/`ia`), conditionals, loops, comments
- Movement keymaps: `]f`/`[f` for next/prev function, `]c`/`[c` for classes, `]a`/`[a` for parameters
- Parameter swapping: `<leader>a`/`<leader>A` to swap with next/prev parameter
- Auto-tag for HTML/PHP/JS/React/TS/Vue files (auto-close, auto-rename, close-on-slash)
- Indent disabled initially (experimental); can enable per-filetype if stable
- 2025-12-07: UX/Editing Phase 6 decisions:
- Enable signcolumn=yes (always show for LSP diagnostics, git signs)
- Enable cursorline (highlight current line)
- Enable colorcolumn=80,120 (visual guides at 80 and 120 chars)
- NO cursorcolumn (as per AGENTS.md)
- NO auto-window toggling behavior (keep settings static, no per-window autocmds)
- NO motion plugin (skip leap/flash for simplicity)
- Undotree moved to separate phase (6.8)
- Comment.nvim for commenting (gcc/gc/gbc/gb keymaps)
- nvim-surround for text objects (ys/ds/cs operators)
- nvim-autopairs for auto-closing brackets/quotes with Treesitter and cmp integration
- indent-blankline for visual indent guides with scope highlighting
- nvim-ufo for enhanced folding with Treesitter/LSP providers (zR/zM/K for peek)
- undotree for visual undo history (<leader>u to toggle)
- 2025-12-07: Git integration Phase 7:
- Gitsigns with minimal config for signs in gutter (add, change, delete markers)
- Hunk navigation: `]h`/`[h` for next/prev hunk
- Hunk actions: stage, reset, preview
- NO inline blame or advanced features (keep minimal)
- 2025-12-07: Copilot Phase 8:
- Integrated via copilot.lua + copilot-cmp (completion source)
- Auto-trigger suggestions as you type
- Copilot suggestions appear before LSP in completion menu (higher priority)
- Enabled for all filetypes
- No specific Copilot keymaps (use existing cmp keymaps)
- Node.js v22.21.1 confirmed working
- 2025-12-07: Formatting & Linting Phase 9:
- **Philosophy**: Formatters are authoritative; Neovim settings match formatter output
- **Formatters**: prettier (JS/TS/CSS/JSON/MD/HTML), phpcbf (PHP/WordPress), stylua (Lua), black (Python)
- **Linters**: eslint_d (JS/TS), phpcs (PHP/WordPress), markdownlint (Markdown), ruff (Python)
- **Strategy**: Project-local executables first (node_modules/.bin/, vendor/bin/), then Mason, then system PATH
- **WordPress**: phpcs/phpcbf already installed globally; use phpcs.xml or --standard=WordPress
- **Format-on-save**: Enabled by default, toggle with `<leader>lt`
- **Manual format**: `<leader>lf` (buffer), `<leader>lf` (visual range)
- **Linting split**: none-ls for formatting only, nvim-lint for diagnostics (none-ls removed linters)
- **Python support**: pyright LSP, black formatter, ruff linter, treesitter parser
- **Per-filetype indentation**: Explicit settings per filetype to match formatters
- PHP: tabs, 2-space display (WordPress standards)
- JS/TS/CSS/JSON/HTML: 2 spaces (Prettier)
- Lua: 2 spaces (common convention)
- Markdown: 2 spaces (Prettier)
- Python: 4 spaces (Black/PEP 8)
- **Global defaults**: 4 spaces (reasonable baseline for other filetypes)
- 2025-12-07: Kept Behaviors Phase 10:
- **Abbreviations**: Common typo corrections (`adn→and`, `waht→what`, `tehn→then`, `functin→function`, `positin→position`) in dedicated `lua/abbreviations.lua` file for modularity
- **Templates**: Shell script template (template.sh) auto-loaded via BufNewFile autocmd for `*.sh` files
- **Whitespace highlighting**: Already handled via `listchars` in Phase 3.2 (settings.lua)
- **Persistent folds**: Not needed; UFO handles folding without explicit persistence mechanism
- 2025-12-11: Colorscheme Phase 11.2:
- **Color palette extraction**: Extracted all 45 color definitions from original Paper Tonic colorscheme
- **Structure**: Created `lua/paper-tonic-modern/colors.lua` with comprehensive documentation
- **Categories**: Background colors (main, UI, highlights, status), foreground colors (text grays, exceptions), alerts/diagnostics, primary accents (brownish-red), and secondary accents (green/blue/cyan/magenta palettes)
- **Format**: Each color defined as `{hex, 256-color, ansi}` tuple for broad terminal compatibility
- **Philosophy**: Light, paper-like theme with subtle colors for long reading sessions
- **Next steps**: Phase 11.3 will create colorscheme structure and entry point
- 2025-12-11: Colorscheme Phase 11.3:
- **Colorscheme structure**: Created complete modular colorscheme architecture
- **Entry point**: `colors/paper-tonic-modern.lua` properly resets and loads colorscheme
- **Main module**: `lua/paper-tonic-modern/init.lua` with helper functions for setting highlights
- **Helper functions**: `M.highlight()` for single groups, `M.highlight_all()` for batch operations
- **Color conversion**: Smart conversion between gui/cterm/ansi formats
- **Group modules**: Created stub files for editor, syntax, treesitter, semantic, lsp, and plugins
- **Loading order**: Structured to load groups in logical sequence (editor → syntax → treesitter → semantic → lsp → plugins)
- **Validation**: Colorscheme loads successfully, highlights applied correctly
- **Language color consistency**: All documentation updated to reflect that each language maintains its color identity everywhere (PHP=primary, HTML=blue, CSS=green, templates=magenta)
- 2025-12-11: Colorscheme Phase 11.4:
- **Editor highlights**: Comprehensive UI element highlighting (Normal, StatusLine, CursorLine, Visual, Search, Pmenu, Folds, Diffs, Spelling, Messages)
- **Syntax highlights**: Traditional Vim syntax groups (Comment, String, Function, Keyword, Type, etc.) with language-specific overrides
- **Language support**: Added specific highlighting for CSS (green/c2), HTML (blue/c3), Lua, Markdown, JSON, JavaScript/TypeScript, PHP
- **Color verification**: All key groups tested and verified (Normal=#8c8c8c on #ffffff, htmlTag=#005faf, cssClassName=#008700)
- **CSS classes**: Green tones (c2) for CSS syntax elements
- **HTML tags**: Blue tones (c3) for HTML structure
- **PHP syntax**: Primary brownish-red tones for PHP keywords/functions
- **Test file**: Created test-colorscheme.lua for visual verification
- 2025-12-11: Colorscheme Phase 11.5:
- **TreeSitter highlights**: Comprehensive modern `@*` highlight groups implemented
- **Core groups**: @variable, @function, @keyword, @string, @number, @boolean, @comment, @type, @property, @operator, @punctuation
- **Language constructs**: @keyword.function, @keyword.return, @keyword.conditional, @keyword.repeat, @keyword.exception
- **Markup**: @markup.strong, @markup.italic, @markup.heading (1-6), @markup.link, @markup.raw, @markup.list
- **Template languages**: @punctuation.special.twig, @keyword.jinja (magenta c5 for template syntax)
- **Diagnostics**: @diff.plus, @diff.minus, @diff.delta
- **Debug tool**: Added `<leader>hi` keymap to show highlight group and resolved colors under cursor
- **Validation**: All TreeSitter groups tested and verified with correct palette colors
- 2025-12-11: Colorscheme Phase 11.6:
- **Language-specific TreeSitter groups**: Enhanced with comprehensive per-language overrides
- **CSS/SCSS**: Properties, variables ($var, --custom), functions, tag selectors (green c2 tones)
- **HTML**: Tags, attributes, delimiters (blue c3 throughout)
- **PHP**: Variables ($var), functions, methods, built-ins ($this, $GLOBALS), properties (primary brownish-red)
- **JavaScript/TypeScript**: Variables, functions, properties, built-ins (this, arguments), JSX/TSX tags (primary + blue for JSX)
- **Lua**: Variables, functions, built-ins (_G, _VERSION), properties (primary)
- **Markdown**: Headings (1-6), links, code blocks, inline code (primary for structure)
- **JSON**: Properties, strings, numbers, booleans (neutral colors)
- **Bash/Shell**: Variables, functions, built-ins, strings (primary)
- **Color consistency verified**: HTML=#005faf (blue), CSS properties=#7c6666 (primary_weak), PHP variables=#7c6666
- **Test files**: Created test-html.html, test-css.css, test-colors.php for validation
- 2025-12-11: Colorscheme Phase 11.7:
- **Semantic highlighting**: Custom TreeSitter captures for cross-language consistency
- **CSS semantic captures**: @CssClassName (green c2), @CssIdentifier (strong green c2_strong, bold), @cssPseudoClass (bold brownish-red primary_strong - distinguishes from green selectors), @cssPseudoElement (bold brownish-red), @cssNestingSelector (strong green), @CssUniversalSelector
- **CSS properties**: @CssProp (primary_weak), @CssPropertyValue (bold fg), @CssUnit (delimiter)
- **CSS media queries**: @cssMediaFeatureName, @cssMediaQuery, @cssMediaQueryValue
- **HTML attributes**: @ClassNameAttribute, @IdAttribute, @DataAttribute (all fg_weak for attribute names)
- **HTML data attributes**: @DataAttributeValue (Function color)
- **Cross-language consistency**: Critical feature - class="my-class" in HTML uses same color (@CssClassName, green c2) as .my-class in CSS; id="my-id" in HTML uses same color (@CssIdentifier, green c2_strong) as #my-id in CSS
- **Visual benefits**: Easy to visually match selectors between HTML and CSS files; consistent color coding across languages
- **Custom queries**: Leverages existing after/queries/css/highlights.scm and after/queries/html/highlights.scm
- **Priority fix**: Added `(#set! priority 200)` to all custom captures to override built-in captures (@string priority 99, @constant default priority)
- **Technical note**: Custom queries require `;extends` directive and higher priority than built-in captures to work correctly
- **Pseudo-class design**: Uses bold brownish-red (primary_strong) instead of green to distinguish behavioral modifiers (:hover, :focus) from structural selectors (.class, #id)
- 2025-12-11: Colorscheme Phase 11.8:
- **LSP highlights**: Comprehensive diagnostic and UI highlights
- **LSP diagnostics**: Error (red #d70000), Warn (orange #d75f00), Info (blue #8989af), Hint (green #89af89)
- **LSP diagnostic UI**: Underlines (undercurl for errors/warnings), signs, floating windows, virtual text with tinted backgrounds
- **LSP references**: Cyan background gradients - Text (#e0eaff subtle), Read (#d4f0ff medium), Write (#a3e0ff strong)
- **LSP semantic tokens**: Fallback groups linking to TreeSitter equivalents for consistency
- **Telescope highlights**: Neutral base with primary accent for matching, selection, and titles
- **Gitsigns highlights**: Status colors - Add (green), Change (blue), Delete (red); inline diff backgrounds
- **nvim-cmp highlights**: Primary tones for item kinds, bold for match highlighting, italic for menu
- **Oil.nvim highlights**: Bold directories, status colors for permissions (read=green, write=orange, execute=blue), operation colors
- **indent-blankline**: Subtle grays for guides and scope
- **nvim-ufo**: Subtle backgrounds for folds with preview support
- 2025-12-11: Colorscheme Phase 11.9:
- **Plugin configuration updated**: `lua/plugins/colorscheme.lua` loads `paper-tonic-modern`
- **Cleanup**: Moved old `paper-tonic/` directory to `legacy/paper-tonic-original/`
- **Validation**: Full config reload tested - all highlight groups load correctly
- **Colorscheme integration**: Native Neovim colorscheme at `colors/paper-tonic-modern.lua`
- **No overrides needed**: Modern implementation doesn't require separate override file
## Project-Local Configuration (design)
Context: Projects can contain multiple git repositories (e.g., WordPress site with theme + multiple plugins). We need a way to set per-project `intelephense.includePaths` and similar without globalizing settings.
Options considered
- Layered JSON files (recommended): `.nvim.json` (committed) + `.nvim.local.json` (gitignored)
- Walk upward from current file; collect and merge configs until reaching a boundary marker or filesystem root.
- Boundary marker: `.nvimroot` to define a workspace that can encompass multiple repos.
- Merge order: top → bottom; nearest wins on conflicts; arrays replace by default unless we later add a merge strategy.
- Pros: safe (data-only), portable, reviewable in PRs.
- Cons: less dynamic than Lua.
- Layered Lua files: `.nvim.lua` + `.nvim.local.lua`
- Pros: maximum flexibility (computed paths).
- Cons: executes code from the repo; security gates required.
- Env/direnv: rejected (decision 2025-12-06).
- Central registry file in `~/.config/nvim/`: possible later for private overrides, but not primary.
Chosen approach (confirmed)
- Use `folke/neoconf.nvim` with `.neoconf.json` at the workspace root (or project roots) to supply LSP/plugin settings. Multi-repo: keep a single `.neoconf.json` at the parent workspace folder and open Neovim from there (or use a rooter later if needed).
Example `.neoconf.json`
```
{
"lspconfig": {
"intelephense": {
"settings": {
"intelephense": {
"environment": {
"includePaths": [
"wp-content/themes/my-theme",
"wp-content/plugins/custom-plugin"
]
}
}
}
}
}
}
```
- Files recognized per directory level:
- `.nvim.json`: checked into VCS; shared per-project defaults.
- `.nvim.local.json`: gitignored; machine-specific overrides.
- Loader behavior:
1. Start at the buffers directory; ascend toward root.
2. Stop at directory containing `.nvimroot` (if found) or at filesystem root.
3. At each level, if `.nvim.json` or `.nvim.local.json` exists, parse and stage for merge.
4. Merge staged configs in ascending order; nearest directory applies last.
- Path resolution:
- Relative paths resolve against the topmost boundary (i.e., `.nvimroot` directory if present; otherwise the highest directory in which a config was found). This allows referencing sibling repos (e.g., theme and plugins) from a single top-level site folder.
Example `.nvim.json`
```
{
"lsp": {
"php": {
"intelephense": {
"includePaths": [
"wp-content/themes/my-theme",
"wp-content/plugins/custom-plugin",
"vendor/some-package/src"
]
}
}
}
}
```
Intended integration
- A helper module `lua/local_config.lua` will expose:
- `load(start_dir) -> table` collecting and merging configs
- `get(path, default)` for reads, e.g., `get({"lsp","php","intelephense","includePaths"}, {})`
- LSP wiring (in Phase 3.5):
- Read includePaths via the helper and pass to `settings.intelephense.environment.includePaths` in `lspconfig.intelephense.setup{}`.
Open items to confirm
- Confirm JSON as the format (vs Lua) for project-local config.
- Confirm `.nvimroot` as the workspace boundary marker name.
- Confirm array merge behavior (replace vs concatenate). Initial proposal: replace.
## LSP Scope (initial)
- Core servers: `lua_ls`, `tsserver`, `html`, `cssls`, `jsonls`, `bashls`
- PHP: `intelephense` (decision)
- Markdown: `marksman` (decision)
- Keep configuration minimal; defer language-specific tuning.
## Text & Editing Settings
- `spelllang = en_gb`
- `listchars` and `showbreak` will reuse legacy values.
- `completeopt = menu,menuone,noselect` for `nvim-cmp`.
## Process Reminders
- After any change or decision, update this README and MIGRATION_PLAN.md.
- Keep subphases small and verify each step in isolation.

View File

@ -0,0 +1,129 @@
# Critical Regression Fix: LSP Project Settings Not Loading (2025-12-07)
## Summary
`gd` (goto definition) stopped working for external library references in `WORKSPACE_TEST/site/external.php`. Even restoring to a git commit where it previously worked didn't fix it, indicating an **environment change** rather than a code regression.
## Root Cause
**Neovim 0.11+ removed support for the `on_new_config` callback in `vim.lsp.config()`.**
The previous implementation used `on_new_config` to load project-local settings from `.nvim.lua`:
```lua
vim.lsp.config(server_name, {
on_new_config = function(new_config, root_dir)
-- Load project settings and merge into new_config.settings
local project_settings = load_project_lsp_settings(server_name, root_dir)
if project_settings.settings then
new_config.settings = vim.tbl_deep_extend("force",
new_config.settings or {},
project_settings.settings)
end
end,
})
```
**Problem**: This callback was **silently ignored** in Neovim 0.11+, resulting in:
- Empty `client.settings` (confirmed via `:LspInfo` showing `Settings: {}`)
- No `includePaths` sent to intelephense
- `gd` failing with "No locations found" for external library symbols
## Symptoms
1. `:LspInfo` showed `Settings: {}` for intelephense
2. `gd` on `\ExtLib\Src\Util::greetExternal()` returned "No locations found"
3. Local (workspace) symbol navigation worked fine
4. Git history restore didn't help (environment issue, not code issue)
## Solution
Use the `LspAttach` autocmd instead of `on_new_config` to load and apply project settings:
```lua
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('lsp_project_settings', { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then return end
-- Load project-specific settings from .nvim.lua at client.root_dir
local project_settings = load_project_lsp_settings(client.name, client.root_dir)
if project_settings.settings then
-- Merge into client.settings
client.settings = vim.tbl_deep_extend("force",
client.settings or {},
project_settings.settings)
-- Notify server of updated settings
vim.schedule(function()
client.notify("workspace/didChangeConfiguration",
{ settings = client.settings })
end)
end
end,
})
```
## Validation
After fix:
```bash
cd WORKSPACE_TEST
nvim --headless +'e site/external.php' +'lua vim.wait(3000); local clients = vim.lsp.get_clients({name="intelephense"}); if clients[1] then print("Settings:", vim.inspect(clients[1].settings)) end' +quit
```
Output:
```lua
Settings: {
intelephense = {
environment = {
includePaths = { "/home/ray/.config/nvim/EXTERNAL_TEST" }
}
}
}
```
✅ Settings now correctly loaded and `gd` works for external symbols.
## Key Differences: Neovim 0.10 vs 0.11 LSP API
### Old API (lspconfig plugin, Neovim < 0.11)
```lua
require('lspconfig').intelephense.setup({
on_new_config = function(new_config, root_dir)
-- Called when creating new client
end,
})
```
### New API (native vim.lsp.config, Neovim 0.11+)
```lua
-- Define config
vim.lsp.config('intelephense', { ... })
-- Enable server
vim.lsp.enable('intelephense')
-- Handle dynamic settings via autocmd
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
-- Access client, load settings, notify server
end,
})
```
## Documentation Updated
- `README.md`: Added decision log entry for 2025-12-07
- `.github/copilot-instructions.md`: Documents LspAttach pattern
- `AGENTS.md`: Already notes "Native exrc + vim.lsp.config migration done"
## Prevention
- Always test LSP functionality after Neovim version upgrades
- Check `:help news` for API changes
- Validate `:LspInfo` settings are populated correctly
- Test with external library references, not just workspace files
## Files Modified
- `lua/plugins/lsp.lua`: Replaced `on_new_config` with `LspAttach` autocmd
## Timeline
- **Before 2025-12-07**: `on_new_config` worked in older Neovim version
- **2025-12-07**: Neovim upgraded to 0.11.5, `on_new_config` silently ignored
- **2025-12-07**: Diagnosed via `:LspInfo` showing empty settings
- **2025-12-07**: Fixed with `LspAttach` pattern, verified working

93
TEST_DIAGNOSTICS.md Normal file
View File

@ -0,0 +1,93 @@
# LSP Diagnostic Test Files
These files are designed to trigger LSP diagnostics of all types to test the Paper Tonic Modern colorscheme's diagnostic virtual text colors.
## Test Files
### test-diagnostics.lua
Lua file with intentional errors for lua_ls (Lua Language Server).
**Expected diagnostics:**
- **Errors** (red): Undefined variables/functions, type mismatches, invalid operations, wrong argument counts
- **Warnings** (orange): Unused variables, shadowing, unreachable code, lowercase globals
- **Hints** (green): Redundant code, style issues
**Note**: lua_ls provides the best mix of diagnostic levels.
### test-diagnostics.php
PHP file with intentional errors for Intelephense (PHP Language Server).
**Expected diagnostics:**
- **Errors** (red): Most issues appear as errors by default in Intelephense
- Undefined functions/variables
- Type mismatches
- Wrong argument counts
- Invalid method calls
**Note**: Intelephense is strict and reports most issues as errors. To see warnings/hints, configure in `.nvim.lua`:
```lua
return {
lsp = {
intelephense = {
settings = {
intelephense = {
diagnostics = {
undefinedSymbols = true,
undefinedVariables = true,
unusedSymbols = "hint", -- Show unused as hints
}
}
}
}
}
}
```
### test-diagnostics.js
JavaScript file with intentional errors for ts_ls (TypeScript Language Server).
**Expected diagnostics:**
- **Errors** (red): Undefined variables/functions, invalid property access, missing parameters
- **Warnings** (orange): Unreachable code, type comparison issues, duplicate cases
- **Hints** (green): const vs let suggestions
- **Info** (blue): Unnecessary operations
## How to Use
1. Open any test file in Neovim:
```bash
nvim test-diagnostics.lua
# or
nvim test-diagnostics.php
# or
nvim test-diagnostics.js
```
2. Wait for LSP to attach and analyze the file (1-2 seconds)
3. Check the virtual text diagnostics at the end of lines with issues
4. Use `:LspInfo` to verify the LSP server is attached
## Color Reference
The Paper Tonic Modern colorscheme uses these colors for diagnostics:
- **DiagnosticError** (virtual text): `#d70000` (bright red) on `#ffefef` background
- **DiagnosticWarn** (virtual text): `#d75f00` (orange) on `#ece0e0` background
- **DiagnosticInfo** (virtual text): `#8989af` (blue) on `#e0e0ec` background
- **DiagnosticHint** (virtual text): `#89af89` (green) on `#e0ece0` background
## Testing Checklist
- [ ] Errors show in red with red undercurl
- [ ] Warnings show in orange with orange undercurl
- [ ] Hints show in green
- [ ] Info messages show in blue
- [ ] Virtual text is readable against light background
- [ ] Sign column icons show correct colors
- [ ] Diagnostic floating windows display correctly
## Debug Command
Use the `<leader>hi` keymap to inspect highlight info under cursor and verify diagnostic colors are applied correctly.

62
after/ftplugin/php.lua Normal file
View File

@ -0,0 +1,62 @@
-- PHP-specific settings and enhancements
-- Loaded automatically for PHP files
-- Enable includeexpr for intelligent gf (goto file) behavior
-- Handles common WordPress/PHP path patterns like:
-- require_once __DIR__ . '/../path/to/file.php';
-- include __FILE__ . '/relative/path.php';
vim.opt_local.includeexpr = "v:lua.resolve_php_gf_path(v:fname)"
-- Global function to resolve PHP file paths for gf command
function _G.resolve_php_gf_path(fname)
local line = vim.api.nvim_get_current_line()
local current_dir = vim.fn.expand('%:p:h')
local current_file = vim.fn.expand('%:p')
-- Pattern 1: __DIR__ . '/path' or __DIR__ . '/../path'
-- Most common in modern PHP/WordPress
local path = line:match("__DIR__%s*%.%s*['\"]([^'\"]+)['\"]")
if path then
path = current_dir .. path
return vim.fn.simplify(path)
end
-- Pattern 2: __FILE__ . '/path'
-- Less common but appears in legacy WordPress code
-- __FILE__ resolves to the current file's full path, so we use its directory
path = line:match("__FILE__%s*%.%s*['\"]([^'\"]+)['\"]")
if path then
-- __FILE__ is the file itself, but when concatenated with a path,
-- it's typically used like __DIR__, so we use the directory
path = current_dir .. path
return vim.fn.simplify(path)
end
-- Pattern 3: dirname(__FILE__) . '/path'
-- Old-style equivalent to __DIR__
path = line:match("dirname%s*%(%s*__FILE__%s*%)%s*%.%s*['\"]([^'\"]+)['\"]")
if path then
path = current_dir .. path
return vim.fn.simplify(path)
end
-- Pattern 4: Simple quoted path in require/include statements
-- Fallback for basic relative paths
path = line:match("require[_%w]*%s*['\"]([^'\"]+)['\"]")
if path then
-- Try relative to current file's directory
path = current_dir .. '/' .. path
return vim.fn.simplify(path)
end
path = line:match("include[_%w]*%s*['\"]([^'\"]+)['\"]")
if path then
-- Try relative to current file's directory
path = current_dir .. '/' .. path
return vim.fn.simplify(path)
end
-- Fallback: return as-is (normal gf behavior)
-- This allows standard gf to work for simple filenames
return fname
end

View File

@ -1,18 +1,42 @@
(id_selector (id_name) @CssIdentifier)
(id_selector (id_name)) @CssIdSelector
(tag_name) @HtmlTagName
;extends
(class_selector (class_name) @CssClassName)
(selectors (pseudo_class_selector (class_name) @cssPseudoClass))
; CSS Selectors - ID selectors (#my-id)
; Priority: Must override default @constant capture
(id_selector "#" @punctuation.delimiter)
(id_selector (id_name) @CssIdentifier (#set! priority 200))
; CSS Selectors - Class selectors (.my-class)
(class_selector "." @punctuation.delimiter)
(class_selector (class_name) @CssClassName (#set! priority 200))
; CSS Selectors - Pseudo-class selectors (:hover, :focus, etc.)
(pseudo_class_selector ":" @punctuation.delimiter)
(pseudo_class_selector (class_name) @cssPseudoClass (#set! priority 200))
; CSS Selectors - Pseudo-element selectors (::before, ::after)
(pseudo_element_selector "::" @punctuation.delimiter)
(pseudo_element_selector (tag_name) @cssPseudoElement (#set! priority 200))
; CSS Selectors - Nesting selector (&)
(nesting_selector) @cssNestingSelector
; need to find out how to make this more specific?
; CSS Selectors - Universal selector (*)
(universal_selector) @CssUniversalSelector
((property_name) (_)) @CssProp
; CSS Selectors - Tag/element selectors (div, p, etc.)
(tag_name) @HtmlTagName
(unit) @CssUnit
; CSS Properties
((property_name) @CssProp)
; CSS Property values
(declaration (property_name) (_) @CssPropertyValue)
(media_statement (feature_query (feature_name) @cssMediaFeatureName (_ (unit) @cssMediaQueryValueUnit) @cssMediaQueryValue) @cssMediaQuery)
; CSS Units (px, em, rem, %, etc.)
(unit) @CssUnit
; CSS Media queries
(media_statement
(feature_query
(feature_name) @cssMediaFeatureName
(_ (unit) @cssMediaQueryValueUnit) @cssMediaQueryValue) @cssMediaQuery)

View File

@ -1,17 +1,20 @@
(start_tag
;extends
; HTML class attribute values - should match CSS .class-name color
; Priority: Must override default @string capture (priority 99)
(attribute
(attribute_name) @ClassNameAttribute (#eq? @ClassNameAttribute "class")
(quoted_attribute_value
(attribute_value) @CssClassName )))
(attribute_value) @CssClassName (#set! priority 200)))
(start_tag
; HTML id attribute values - should match CSS #id-name color
(attribute
(attribute_name) @IdAttribute (#eq? @IdAttribute "id")
(quoted_attribute_value
(attribute_value) @CssIdentifier )))
(attribute_value) @CssIdentifier (#set! priority 200)))
(start_tag
; HTML data-* attributes
(attribute
(attribute_name) @DataAttribute (#match? @DataAttribute "^data-")
(quoted_attribute_value
(attribute_value) @DataAttributeValue )))
(attribute_value) @DataAttributeValue (#set! priority 200)))

View File

@ -0,0 +1,18 @@
-- Paper Tonic Modern
-- A light, paper-like colorscheme for Neovim
-- Forked from the original Paper Tonic with modern Lua implementation
-- Reset highlights and syntax
vim.cmd('highlight clear')
if vim.fn.exists('syntax_on') then
vim.cmd('syntax reset')
end
-- Set colorscheme name
vim.g.colors_name = 'paper-tonic-modern'
-- Set background to light
vim.o.background = 'light'
-- Load the colorscheme
require('paper-tonic-modern').load()

44
eslint.config.js Normal file
View File

@ -0,0 +1,44 @@
// ESLint 9+ flat config format (global default)
// See: https://eslint.org/docs/latest/use/configure/configuration-files
export default [
{
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
// Browser globals
console: "readonly",
window: "readonly",
document: "readonly",
navigator: "readonly",
// Node.js globals
process: "readonly",
__dirname: "readonly",
__filename: "readonly",
require: "readonly",
module: "readonly",
exports: "readonly",
global: "readonly",
Buffer: "readonly",
},
},
rules: {
// Recommended rules
"no-undef": "error",
"no-unused-vars": "warn",
"no-unreachable": "warn",
"no-constant-condition": "error",
"no-duplicate-case": "error",
// Best practices
"eqeqeq": ["warn", "always"],
"no-implicit-globals": "warn",
// Style (minimal)
"semi": ["warn", "always"],
"quotes": ["warn", "double", { "avoidEscape": true }],
},
},
];

28
init.lua Normal file
View File

@ -0,0 +1,28 @@
-- Leader keys early
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Load basic settings, keymaps, autocmds (kept minimal for now)
require('settings')
require('netrw-config')
require('keymaps')
require('autocmds')
require('abbreviations')
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git', 'clone', '--filter=blob:none', '--single-branch',
'https://github.com/folke/lazy.nvim.git', lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Setup plugin system (plugins will be added incrementally)
require('lazy').setup({
spec = {
{ import = 'plugins' },
},
})

31
lazy-lock.json Normal file
View File

@ -0,0 +1,31 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
"copilot.lua": { "branch": "master", "commit": "efe563802a550b7f1b7743b007987e97cba22718" },
"gitsigns.nvim": { "branch": "main", "commit": "5813e4878748805f1518cee7abb50fd7205a3a48" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0b9bb925c000ae649ff7e7149c8cd00031f4b539" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" },
"mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" },
"none-ls.nvim": { "branch": "main", "commit": "5abf61927023ea83031753504adb19630ba80eef" },
"nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" },
"nvim-cmp": { "branch": "main", "commit": "d97d85e01339f01b842e6ec1502f639b080cb0fc" },
"nvim-lint": { "branch": "master", "commit": "ebe535956106c60405b02220246e135910f6853d" },
"nvim-lspconfig": { "branch": "master", "commit": "9c923997123ff9071198ea3b594d4c1931fab169" },
"nvim-surround": { "branch": "main", "commit": "fcfa7e02323d57bfacc3a141f8a74498e1522064" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" },
"nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
"nvim-ufo": { "branch": "main", "commit": "72d54c31079d38d8dfc5456131b1d0fb5c0264b0" },
"oil.nvim": { "branch": "master", "commit": "cbcb3f997f6f261c577b943ec94e4ef55108dd95" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" }
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More