From 0685135ccfa2a9c1483111d456e09b414ea5f05b Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 7 Dec 2025 23:20:15 +0000 Subject: [PATCH] copnfigure folding --- README.md | 29 +++++++++++++++++++++++++++++ lua/plugins/ufo.lua | 33 +++++++++++++++++++++++++++++++-- lua/settings.lua | 29 +++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46c4066..ba9f0c3 100644 --- a/README.md +++ b/README.md @@ -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 (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 `lt` + - **Manual format**: `lf` (buffer), `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) diff --git a/lua/plugins/ufo.lua b/lua/plugins/ufo.lua index 476f0cb..d5e053c 100644 --- a/lua/plugins/ufo.lua +++ b/lua/plugins/ufo.lua @@ -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) diff --git a/lua/settings.lua b/lua/settings.lua index 19ae9c0..9f30fde 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -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