configure formatters and linters

This commit is contained in:
Ray Elliott 2025-12-07 22:33:00 +00:00
commit b045d7c627
5 changed files with 269 additions and 7 deletions

View file

@ -260,13 +260,50 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date.
## Phase 9 — Formatting & Linting
## Phase 9.1 — Confirm scope and priorities
- [ ] Confirm scope and priorities for this phase
- [x] Confirm scope and priorities for this phase
- [x] Decision: Formatters - prettier (JS/TS/CSS/JSON/MD/HTML), phpcbf (PHP), stylua (Lua)
- [x] Decision: Linters - eslint (JS/TS), phpcs (PHP), markdownlint (Markdown)
- [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, 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
- [ ] Add `nvimtools/none-ls.nvim`
- [ ] Configure formatters (to be determined in 9.1)
- [ ] Configure linters (to be determined in 9.1)
- [ ] Add format-on-save or manual format keymaps
## 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
- [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
- [ ] Configure per-filetype settings to match formatter defaults
- [ ] PHP: Match phpcs/WordPress standards (likely tabs, 4-width)
- [ ] JS/TS/CSS/JSON: Match prettier defaults (likely 2 spaces)
- [ ] Lua: Match stylua defaults (likely tabs or 4 spaces)
- [ ] Use autocmds or after/ftplugin/ for filetype-specific tabstop, shiftwidth, expandtab
- [ ] Goal: Manual editing feels natural and matches what formatter will produce on save
## Phase 10 — Migrate Kept Behaviours