copnfigure folding

This commit is contained in:
Ray Elliott 2025-12-07 23:20:15 +00:00
parent b9d9f7e264
commit 0685135ccf
3 changed files with 89 additions and 2 deletions

View File

@ -49,6 +49,35 @@ Record every decision here with a short rationale. Append new entries; do not re
- 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)
## Project-Local Configuration (design)

View File

@ -41,14 +41,43 @@ return {
jumpBot = ']',
},
},
-- Custom fold text showing line count
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (' %d lines '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, {chunkText, hlGroup})
chunkWidth = vim.fn.strdisplaywidth(chunkText)
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, {suffix, 'MoreMsg'})
return newVirtText
end,
},
config = function(_, opts)
-- Set fold settings for nvim-ufo
vim.o.foldcolumn = '1' -- Show fold column
vim.o.foldcolumn = '0' -- Hide fold column (we don't need it)
vim.o.foldlevel = 99 -- Open all folds by default
vim.o.foldlevelstart = 99 -- Open all folds when opening a file
vim.o.foldenable = true -- Enable folding
-- Use simple characters for fold indicators
-- Use simple characters for fold indicators (though foldcolumn is hidden)
vim.o.fillchars = [[eob: ,fold: ,foldopen:▼,foldsep: ,foldclose:▶]]
require('ufo').setup(opts)

View File

@ -41,3 +41,32 @@ vim.opt.tabstop = 4 -- Display tabs as 4 spaces
vim.opt.shiftwidth = 4 -- Indent by 4
vim.opt.softtabstop = 4 -- Backspace removes 4 spaces
vim.opt.expandtab = true -- Use spaces by default (overridden per-filetype)
-- LSP diagnostics configuration
vim.diagnostic.config({
virtual_text = {
spacing = 4,
prefix = '',
-- Show severity (ERROR, WARN, INFO, HINT)
format = function(diagnostic)
return string.format("%s: %s", diagnostic.source or "", diagnostic.message)
end,
},
signs = true, -- Keep signs in signcolumn
underline = true, -- Underline problematic text
update_in_insert = false, -- Don't update diagnostics while typing
severity_sort = true, -- Sort by severity (errors first)
float = {
border = 'rounded',
source = 'always', -- Show diagnostic source
header = '',
prefix = '',
},
})
-- Diagnostic signs in signcolumn
local signs = { Error = "E", Warn = "W", Hint = "H", Info = "I" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end