From fc250c0be26d9ad085fe70c6997af9fa4907fd9b Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 8 Dec 2025 00:06:52 +0000 Subject: [PATCH] add abbreviations --- .github/copilot-instructions.md | 2 ++ AGENTS.md | 5 +++-- MIGRATION_PLAN.md | 18 +++++++++++++----- README.md | 5 +++++ init.lua | 1 + lua/abbreviations.lua | 10 ++++++++++ lua/autocmds.lua | 13 +++++++++++++ 7 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 lua/abbreviations.lua diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 616d0f3..7e0053f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -14,6 +14,8 @@ Modern Lua-first Neovim configuration using lazy.nvim, currently in active migra │ ├── 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 diff --git a/AGENTS.md b/AGENTS.md index 19c22dc..2364acb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,17 +27,18 @@ This repository is being migrated to a modern, minimal Neovim setup driven by Lu ├── 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 - ├── neo-tree.lua ├── telescope.lua ├── treesitter.lua ├── cmp.lua ├── lsp.lua ├── copilot.lua + ├── oil.lua ├── ufo.lua ├── gitsigns.lua - ├── markdown.lua └── none-ls.lua ``` diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 07368c5..3ab9485 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -312,19 +312,27 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date. ## Phase 10 — Migrate Kept Behaviours ## Phase 10.1 — Confirm scope and priorities -- [ ] Confirm scope and priorities for this phase +- [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 -- [ ] Abbreviations: `adn→and`, `waht→what`, `tehn→then`, `functin→function`, `positin→position` +- [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 -- [ ] Templates: auto-populate new `.sh` from template +- [x] Templates: auto-populate new `.sh` from template +- [x] Added BufNewFile autocmd for *.sh in lua/autocmds.lua ## Phase 10.4 — Whitespace highlighting -- [ ] Whitespace highlighting (modern approach) +- [x] Whitespace highlighting (modern approach) +- [x] Note: Already handled via listchars in Phase 3.2 (settings.lua) ## Phase 10.5 — Persistent folds -- [ ] Persistent folds (via UFO) +- [x] Persistent folds (via UFO) -- no need, this is no longer required. +- [x] Note: UFO handles folding; no explicit persistence mechanism needed ## Phase 11 — Cleanup & Validation diff --git a/README.md b/README.md index ba9f0c3..1c08659 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,11 @@ Record every decision here with a short rationale. Append new entries; do not re - 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 ## Project-Local Configuration (design) diff --git a/init.lua b/init.lua index 233c95d..dcda789 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,7 @@ require('settings') require('netrw-config') require('keymaps') require('autocmds') +require('abbreviations') -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' diff --git a/lua/abbreviations.lua b/lua/abbreviations.lua new file mode 100644 index 0000000..9f339e2 --- /dev/null +++ b/lua/abbreviations.lua @@ -0,0 +1,10 @@ +-- Abbreviations (common typo corrections) +-- Phase 10.2: Insert-mode abbreviations for frequent typos + +vim.cmd.iabbrev('adn', 'and') +vim.cmd.iabbrev('waht', 'what') +vim.cmd.iabbrev('tehn', 'then') +vim.cmd.iabbrev('functin', 'function') +vim.cmd.iabbrev('positin', 'position') + +return {} diff --git a/lua/autocmds.lua b/lua/autocmds.lua index 01fa9ba..412149f 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -1,6 +1,19 @@ -- Non-plugin autocommands (minimal placeholder for bootstrap) local aug = vim.api.nvim_create_augroup('UserDefaults', { clear = true }) +-- Phase 10.3: Templates (auto-populate new files from templates) +local template_aug = vim.api.nvim_create_augroup('Templates', { clear = true }) + +vim.api.nvim_create_autocmd("BufNewFile", { + group = template_aug, + pattern = "*.sh", + callback = function() + -- Read template at top of file, then move to end + vim.cmd('0read ~/.config/nvim/templates/template.sh') + vim.cmd('normal! G') + end, +}) + -- Phase 9.4: Per-filetype indentation settings to match formatters -- PHP: WordPress coding standards (tabs, displayed as 2 spaces)