From cd817820caa7f4c6e5e6ff82b437898a70283e04 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Date: Sat, 10 Jan 2026 22:13:59 -0500 Subject: [PATCH] Refactor config: fix conflicts, add features, update docs - Fix keymap conflicts: session (sS/sR), substitute (sl) - Remove duplicate keymaps (window, resize) and options (synmaxcol, foldmethod) - Add which-key group names for better keymap organization - Add auto-format on save with smart filtering (conform.nvim) - Add diagnostic float on hover (CursorHold) - Add safe buffer close with unsaved changes confirmation - Add quickfix/location list navigation keymaps - Add startup config validation (nvim version, executables) - Enable plugin update notifications in lazy.nvim - Clean up: remove temporary files (kkk, cleanup script) - Clean up: remove commented code and fix double function loading - Update README.md with comprehensive documentation - Add CHANGELOG.md tracking all changes --- CHANGELOG.md | 154 ++++++ IMPROVEMENTS.md | 644 -------------------------- LUA_CONFIGURATION_FIXES.md | 159 ------- README.md | 249 ++++++---- cleanup_deprecated_adapters.lua | 28 -- kkk | 100 ---- lua/cargdev/core/init.lua | 77 ++- lua/cargdev/core/keymaps/general.lua | 8 +- lua/cargdev/core/keymaps/personal.lua | 63 ++- lua/cargdev/core/keymaps/plugins.lua | 14 +- lua/cargdev/core/options.lua | 7 +- lua/cargdev/lazy.lua | 3 +- lua/cargdev/plugins/formatting.lua | 29 +- lua/cargdev/plugins/lualine.lua | 9 +- lua/cargdev/plugins/which-key.lua | 39 +- 15 files changed, 490 insertions(+), 1093 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 IMPROVEMENTS.md delete mode 100644 LUA_CONFIGURATION_FIXES.md delete mode 100644 cleanup_deprecated_adapters.lua delete mode 100644 kkk diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1559871 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,154 @@ +# Changelog + +All notable changes to this Neovim configuration will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +--- + +## [Unreleased] + +### Added +- **Which-Key Group Names**: Added organized group names for better keymap discoverability + - Groups: Buffer, Code/Copilot, Debug, Explorer, Find/Files, Git, LSP, Format, Quickfix, Session, Tab/Terminal, Trouble, Copilot Chat +- **Auto-Format on Save**: Enabled smart auto-formatting with conform.nvim + - Skips certain filetypes (sql, markdown) + - Skips files in node_modules + - Added `:FormatToggle` command to enable/disable +- **Diagnostic Float on Hover**: Diagnostics now appear automatically when cursor holds +- **Safe Buffer Close**: `bd` now prompts for unsaved changes + - Options: Save & Close, Discard & Close, Cancel + - `bD` for force close without confirmation +- **Quickfix Navigation Keymaps**: + - `qn` - Next quickfix item + - `qp` - Previous quickfix item + - `qo` - Open quickfix list + - `qq` - Close quickfix list + - `qf` - First quickfix item + - `ql` - Last quickfix item +- **Location List Navigation Keymaps**: + - `ln` - Next location item + - `lp` - Previous location item + - `lo` - Open location list + - `lq` - Close location list +- **Configuration Validation**: Startup checks for: + - Neovim version (0.9+ recommended) + - Required executables (git, rg, node) +- **Plugin Update Notifications**: Lazy.nvim now notifies about available updates (daily check) +- **CheckConfig Command**: Quick access to health checks + +### Changed +- **Session Keymaps**: Renamed to avoid conflicts with substitute + - `ss` โ†’ `sS` (Session Save) + - `sr` โ†’ `sR` (Session Restore) +- **Substitute Keymaps**: Reorganized to avoid conflicts + - `ss` โ†’ `sl` (Substitute Line) + - `sub` remains for substitute with motion + - `S` remains for substitute to end of line +- **Keymap Descriptions**: Standardized format (e.g., "Session: Save", "Substitute: Line") + +### Fixed +- **Duplicate Window Management Keymaps**: Removed duplicates from `personal.lua`, centralized in `window.lua` +- **Duplicate Resize Keymaps**: Removed duplicates, centralized in `window.lua` +- **Redundant Filetype Detection**: Now only runs if filetype is not already detected +- **Double Function Loading**: Functions now load once on VimEnter with flag protection +- **Duplicate synmaxcol Setting**: Removed duplicate (was 240 then 200), kept 200 +- **Duplicate foldmethod Setting**: Removed duplicate, kept `indent` (faster than `syntax`) +- **Duplicate foldlevel Setting**: Removed duplicate setting +- **Environment Variable Validation**: `IDEA_DIR` now validated before Obsidian link setup + +### Removed +- **Temporary Files**: + - `kkk` - Unknown purpose temporary file + - `cleanup_deprecated_adapters.lua` - Cleanup script no longer needed +- **IMPROVEMENTS.md**: All issues resolved, file removed +- **Commented Code**: + - Tmux navigation keymaps from `personal.lua` + - Commented `x` keymap explanation from `general.lua` + - Commented `project_config` bootstrap from `init.lua` + +### Performance +- Optimized filetype detection (conditional execution) +- Reduced redundant option settings +- Single function loading instead of double + +--- + +## [Previous] - Pre-Changelog + +### Features Present +- Lazy.nvim plugin management +- Full LSP support with Mason +- nvim-cmp completion +- Snacks.nvim + Telescope file navigation +- nvim-tree file explorer +- LazyGit integration +- GitHub Copilot + Copilot Chat +- DAP debugging with UI +- Conform.nvim formatting +- Trouble.nvim diagnostics +- Native auto-wrapping configuration +- Custom lualine theme with word count + +### Migration History +- Migrated from Telescope to Snacks for primary navigation +- Kept Telescope for git-specific features +- See [TELESCOPE_TO_SNACKS_MIGRATION.md](./TELESCOPE_TO_SNACKS_MIGRATION.md) for details + +--- + +## File Changes Summary + +### Modified Files +| File | Changes | +|------|---------| +| `lua/cargdev/core/keymaps/personal.lua` | Removed duplicates, added quickfix/location keymaps, safe buffer close | +| `lua/cargdev/core/keymaps/plugins.lua` | Fixed session/substitute keymap conflicts | +| `lua/cargdev/core/keymaps/general.lua` | Added vault_path validation, removed commented code | +| `lua/cargdev/core/keymaps/window.lua` | Centralized window management keymaps | +| `lua/cargdev/core/init.lua` | Fixed double loading, added diagnostic hover, config validation | +| `lua/cargdev/core/options.lua` | Removed duplicate settings (synmaxcol, foldmethod, foldlevel) | +| `lua/cargdev/plugins/which-key.lua` | Added group names configuration | +| `lua/cargdev/plugins/formatting.lua` | Enabled auto-format on save with smart filtering | +| `lua/cargdev/lazy.lua` | Enabled plugin update notifications | +| `README.md` | Complete rewrite with proper documentation | + +### Deleted Files +| File | Reason | +|------|--------| +| `kkk` | Temporary file, unknown purpose | +| `cleanup_deprecated_adapters.lua` | One-time cleanup script, no longer needed | +| `IMPROVEMENTS.md` | All issues resolved | + +### New Files +| File | Purpose | +|------|---------| +| `CHANGELOG.md` | Track configuration changes | + +--- + +## Keymap Reference + +### New/Changed Keymaps + +| Keymap | Action | File | +|--------|--------|------| +| `sS` | Session: Save | plugins.lua | +| `sR` | Session: Restore | plugins.lua | +| `sl` | Substitute: Line | plugins.lua | +| `bd` | Buffer: Close (safe) | personal.lua | +| `bD` | Buffer: Force close | personal.lua | +| `qn` | Quickfix: Next | personal.lua | +| `qp` | Quickfix: Previous | personal.lua | +| `qo` | Quickfix: Open | personal.lua | +| `qq` | Quickfix: Close | personal.lua | +| `qf` | Quickfix: First | personal.lua | +| `ql` | Quickfix: Last | personal.lua | +| `ln` | Location: Next | personal.lua | +| `lp` | Location: Previous | personal.lua | +| `lo` | Location: Open | personal.lua | +| `lq` | Location: Close | personal.lua | + +--- + +*Last Updated: January 2026* diff --git a/IMPROVEMENTS.md b/IMPROVEMENTS.md deleted file mode 100644 index 4f85d69..0000000 --- a/IMPROVEMENTS.md +++ /dev/null @@ -1,644 +0,0 @@ -# Neovim Configuration Improvements & Recommendations - -**Generated:** 2024 -**Status:** Analysis Complete - ---- - -## ๐Ÿ“‹ Table of Contents - -1. [Critical Issues](#critical-issues) -2. [Keymap Conflicts & Duplicates](#keymap-conflicts--duplicates) -3. [Code Quality & Organization](#code-quality--organization) -4. [Performance Optimizations](#performance-optimizations) -5. [Missing Features & Enhancements](#missing-features--enhancements) -6. [Documentation Updates](#documentation-updates) -7. [Plugin Management](#plugin-management) -8. [Security & Best Practices](#security--best-practices) -9. [Quick Wins](#quick-wins) - ---- - -## ๐Ÿ”ด Critical Issues - -### 1. โœ… **Duplicate Copilot Panel Keymaps** (FIXED) -**Location:** `lua/cargdev/core/keymaps/personal.lua` and `lua/cargdev/core/keymaps/copilot.lua` - -**Issue:** `cp` was mapped in both files. Also had conflict with `ce` (enable vs explain). - -**Resolution:** -- Removed duplicate `cp` from `personal.lua` -- Removed conflicting `ce` from `personal.lua` (Copilot enable in `copilot.lua` takes precedence) -- All Copilot panel keymaps now centralized in `copilot.lua` - -**Priority:** ๐Ÿ”ด High โœ… Fixed - ---- - -### 2. **Duplicate Window Management Keymaps** -**Location:** `lua/cargdev/core/keymaps/personal.lua` and `lua/cargdev/core/keymaps/window.lua` - -**Issue:** Window split keymaps (`sv`, `sh`, etc.) are duplicated. - -**Impact:** Redundant code, maintenance burden. - -**Recommendation:** -```lua --- Consolidate all window management in window.lua --- Remove duplicates from personal.lua -``` - -**Priority:** ๐ŸŸก Medium - ---- - -## โš ๏ธ Keymap Conflicts & Duplicates - -### 4. **Session Management Keymap Conflict** -**Location:** `lua/cargdev/core/keymaps/plugins.lua` (lines 46-47) and `lua/cargdev/core/keymaps/personal.lua` (line 22) - -**Issue:** -- `plugins.lua`: `ss` = SessionSave -- `personal.lua`: `so` = Reload nvim (source %) - -**Note:** These don't conflict directly, but `ss` conflicts with Substitute line in `plugins.lua` line 54. - -**Recommendation:** -```lua --- Rename session save/restore to avoid confusion: --- sS = SessionSave --- sR = SessionRestore --- Or use a dedicated prefix: se (session) -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 5. **Substitute Keymap Already Conflicts** -**Location:** `lua/cargdev/core/keymaps/plugins.lua` line 54 - -**Issue:** `ss` is used for both SessionSave and Substitute line. - -**Current State:** Comment says "changed from s to sub to avoid conflicts" but `ss` still conflicts. - -**Recommendation:** -```lua --- Use subs for substitute line --- Keep ss for session save --- Or use sS for session save -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 6. **Tab Keymap Conflicts** -**Location:** Multiple files handle Tab key - -**Issue:** Tab is handled by: -- Copilot keymaps (`copilot.lua`) -- nvim-cmp (`nvim-cmp.lua`) -- Both coordinate, but could be cleaner - -**Current State:** โœ… Working correctly with coordination, but could be documented better. - -**Recommendation:** -- Add comments explaining the coordination -- Consider using a unified handler function - -**Priority:** ๐ŸŸข Low (working, but could be cleaner) - ---- - -## ๐Ÿงน Code Quality & Organization - -### 7. **Temporary/Unused Files** -**Location:** Root directory - -**Files Found:** -- `kkk` - Unknown purpose, appears to be temporary -- `cleanup_deprecated_adapters.lua` - Cleanup script that may not be needed anymore - -**Recommendation:** -```bash -# Review and remove if not needed: -- kkk -- cleanup_deprecated_adapters.lua (if cleanup already done) -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 8. **Commented Code Should Be Removed** -**Location:** Multiple files - -**Examples:** -- `lua/cargdev/core/keymaps/personal.lua` lines 66-69 (commented Tmux navigation) -- `lua/cargdev/core/keymaps/general.lua` line 12 (commented x keymap) -- `lua/cargdev/core/init.lua` lines 58-64 (commented project_config bootstrap) - -**Recommendation:** -```lua --- Remove commented code or convert to proper documentation --- Use git history if you need to reference old code -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 9. **Inconsistent Keymap Description Format** -**Location:** Various keymap files - -**Issue:** Some descriptions are verbose, some are brief. No consistent style. - -**Examples:** -- `{ desc = "Toggle comment" }` vs `{ desc = "Copilot: Accept suggestion" }` -- Some use prefixes (Copilot:, Git:), some don't - -**Recommendation:** -```lua --- Standardize description format: --- For plugin-specific: "PluginName: Action" --- For general: "Action" --- Example: { desc = "Copilot: Accept suggestion" } --- Example: { desc = "Toggle comment" } -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 10. **Unused Variables in general.lua** -**Location:** `lua/cargdev/core/keymaps/general.lua` line 19 - -**Issue:** `vault_path` is defined but only used if Obsidian link function is called. - -**Recommendation:** -```lua --- Move vault_path inside the function or add a check: -local vault_path = vim.env.IDEA_DIR -if not vault_path then - vim.notify("IDEA_DIR environment variable not set", vim.log.levels.WARN) - return -end -``` - -**Priority:** ๐ŸŸข Low - ---- - -## โšก Performance Optimizations - -### 11. **Redundant Filetype Detection** -**Location:** `lua/cargdev/core/init.lua` lines 37-42 - -**Issue:** Force filetype detection on every BufRead might be redundant. - -**Current Code:** -```lua -vim.api.nvim_create_autocmd("BufRead", { - pattern = "*", - callback = function() - vim.cmd("silent filetype detect") - end, -}) -``` - -**Recommendation:** -```lua --- Only run if filetype is not already detected: -vim.api.nvim_create_autocmd("BufRead", { - pattern = "*", - callback = function() - if vim.bo.filetype == "" then - vim.cmd("silent filetype detect") - end - end, -}) -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 12. **Double Function Loading** -**Location:** `lua/cargdev/core/init.lua` lines 44-56 - -**Issue:** Functions are loaded twice - once immediately and once on VimEnter. - -**Recommendation:** -```lua --- Remove the immediate load, keep only VimEnter --- Or add a flag to prevent double-loading -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 13. **Syntax Highlighting Column Limit Set Twice** -**Location:** `lua/cargdev/core/options.lua` lines 43 and 52 - -**Issue:** `synmaxcol` is set to 240 and then 200. - -**Recommendation:** -```lua --- Remove duplicate, keep only one value (200 is more conservative) -opt.synmaxcol = 200 -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 14. **Foldmethod Set Twice** -**Location:** `lua/cargdev/core/options.lua` lines 54 and 105 - -**Issue:** `foldmethod` is set to "syntax" then "indent". - -**Recommendation:** -```lua --- Choose one method or make it filetype-specific --- "indent" is generally faster than "syntax" -``` - -**Priority:** ๐ŸŸก Medium - ---- - -## โœจ Missing Features & Enhancements - -### 15. **Missing Which-Key Integration** -**Location:** `lua/cargdev/plugins/which-key.lua` exists but keymaps may not be registered - -**Recommendation:** -```lua --- Ensure all keymaps use proper descriptions for which-key --- Add group names for better organization --- Example: { desc = "Copilot: Accept", group = "Copilot" } -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 16. **No Auto-Format on Save** -**Location:** Formatting plugin exists but no autocmd for auto-format - -**Recommendation:** -```lua --- Add to formatting.lua or create autocmd: -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*", - callback = function() - if vim.bo.filetype ~= "" then - vim.lsp.buf.format({ async = false }) - end - end, -}) -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 17. **Missing Diagnostic Float on Hover** -**Location:** LSP config - -**Issue:** `K` shows documentation, but diagnostic hover could be enhanced. - -**Recommendation:** -```lua --- Add diagnostic hover enhancement: -vim.api.nvim_create_autocmd("CursorHold", { - callback = function() - vim.diagnostic.open_float(nil, { focus = false }) - end, -}) -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 18. **No Buffer Close Confirmation for Unsaved Changes** -**Location:** Buffer management - -**Recommendation:** -```lua --- Add safe buffer close: -keymap.set("n", "bd", function() - if vim.bo.modified then - vim.ui.select({ "Save", "Discard", "Cancel" }, { - prompt = "Buffer has unsaved changes:" - }, function(choice) - if choice == "Save" then - vim.cmd("w") - vim.cmd("bd") - elseif choice == "Discard" then - vim.cmd("bd!") - end - end) - else - vim.cmd("bd") - end -end, { desc = "Close buffer (safe)" }) -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 19. **Missing Quickfix Navigation Enhancements** -**Location:** Quickfix/Trouble integration - -**Recommendation:** -```lua --- Add quickfix navigation: -keymap.set("n", "qn", ":cnext", { desc = "Next quickfix" }) -keymap.set("n", "qp", ":cprev", { desc = "Previous quickfix" }) -keymap.set("n", "qq", ":cclose", { desc = "Close quickfix" }) -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 20. **No Project Root Detection Enhancement** -**Location:** Project config - -**Recommendation:** -```lua --- Add better project root detection using: --- - .git directory --- - package.json, Cargo.toml, etc. --- - Consider using nvim-lspconfig's root_dir patterns -``` - -**Priority:** ๐ŸŸข Low - ---- - -## ๐Ÿ“š Documentation Updates - -### 21. **README.md is Outdated** -**Location:** Root `README.md` - -**Issue:** README contains Tmux/Vim keymaps, not Neovim-specific information. - -**Recommendation:** -- Update README with: - - Neovim version requirements - - Installation instructions - - Plugin list - - Keymap reference (link to keyboard_mappings.md) - - Configuration structure - - Troubleshooting section - -**Priority:** ๐ŸŸก Medium - ---- - -### 22. **Missing Keymap Documentation** -**Location:** Various keymap files - -**Issue:** Not all keymaps are documented in `keyboard_mappings.md`. - -**Recommendation:** -- Update `keyboard_mappings.md` with all current keymaps -- Organize by category -- Add search functionality or table of contents - -**Priority:** ๐ŸŸก Medium - ---- - -### 23. **Plugin Documentation Missing** -**Location:** No central plugin documentation - -**Recommendation:** -- Create `PLUGINS.md` documenting: - - What each plugin does - - Why it's included - - Configuration highlights - - Dependencies - -**Priority:** ๐ŸŸข Low - ---- - -## ๐Ÿ”Œ Plugin Management - -### 24. **Potential Plugin Redundancy** -**Location:** Multiple plugins for similar functionality - -**Examples:** -- `telescope.lua` and `snacks.lua` - Both are file pickers (Snacks is replacement) -- `substitute.lua` and native Neovim features - -**Recommendation:** -- Review if Telescope is still needed after Snacks migration -- Document which plugins are being phased out - -**Priority:** ๐ŸŸก Medium - ---- - -### 25. **Missing Plugin Health Checks** -**Location:** No health check automation - -**Recommendation:** -```lua --- Add to init.lua or create health check: -vim.api.nvim_create_user_command("CheckConfig", function() - vim.cmd("checkhealth") - -- Add custom checks for: - -- - Required plugins installed - -- - LSP servers available - -- - Keymap conflicts -end, {}) -``` - -**Priority:** ๐ŸŸข Low - ---- - -### 26. **No Plugin Update Reminder** -**Location:** Lazy.nvim config - -**Recommendation:** -```lua --- Enable update notifications: -require("lazy").setup({ - checker = { - enabled = true, - notify = true, -- Change from false to true - frequency = 3600, -- Check every hour - }, -}) -``` - -**Priority:** ๐ŸŸข Low - ---- - -## ๐Ÿ”’ Security & Best Practices - -### 27. **Modeline Disabled (Good)** -**Status:** โœ… Already disabled in `options.lua` line 59 - -**Note:** Good security practice, keep it disabled. - ---- - -### 28. **Missing Secure Defaults for Netrw** -**Status:** โœ… Netrw is disabled (good) - -**Note:** Consider documenting why it's disabled. - ---- - -### 29. **Environment Variable Usage** -**Location:** `general.lua` line 19 - -**Issue:** Uses `vim.env.IDEA_DIR` without validation. - -**Recommendation:** -```lua --- Add validation: -local vault_path = vim.env.IDEA_DIR -if not vault_path or vault_path == "" then - return -- Don't set up Obsidian links if not configured -end -``` - -**Priority:** ๐ŸŸข Low - ---- - -## ๐ŸŽฏ Quick Wins - -### 30. **Add Statusline Customization** -**Location:** `lualine.lua` - -**Recommendation:** -- Add git branch indicator -- Add LSP status -- Add file encoding -- Add word count for markdown files - -**Priority:** ๐ŸŸข Low - ---- - -### 31. **Add File Explorer Enhancements** -**Location:** `nvim-tree.lua` - -**Recommendation:** -- Add file creation from explorer -- Add better file preview -- Add git status indicators - -**Priority:** ๐ŸŸข Low - ---- - -### 32. **Add Better Error Handling** -**Location:** Various files - -**Recommendation:** -```lua --- Wrap plugin requires in pcall: -local ok, plugin = pcall(require, "plugin-name") -if not ok then - vim.notify("Plugin failed to load: plugin-name", vim.log.levels.WARN) - return -end -``` - -**Priority:** ๐ŸŸก Medium - ---- - -### 33. **Add Configuration Validation** -**Location:** Core init - -**Recommendation:** -```lua --- Add startup validation: -local function validate_config() - -- Check Neovim version - if vim.fn.has("nvim-0.9") == 0 then - vim.notify("Neovim 0.9+ required", vim.log.levels.ERROR) - end - -- Check required commands - -- Check required plugins -end -``` - -**Priority:** ๐ŸŸข Low - ---- - -## ๐Ÿ“Š Summary Statistics - -- **Total Issues Found:** 32 -- **Critical (High Priority):** 2 (2 fixed) -- **Medium Priority:** 12 -- **Low Priority:** 18 -- **Already Fixed/Good:** 2 - ---- - -## ๐Ÿš€ Recommended Action Plan - -### Phase 1: Critical Fixes (Do First) -1. โœ… Fix duplicate git conflict keymaps (FIXED) -2. โœ… Fix duplicate Copilot keymaps (FIXED) -3. Resolve substitute/session keymap conflict - -### Phase 2: Code Quality (Do Next) -4. Remove temporary files -5. Clean up commented code -6. Fix duplicate settings (synmaxcol, foldmethod) -7. Standardize keymap descriptions - -### Phase 3: Enhancements (Do When Time Permits) -8. Add auto-format on save -9. Update documentation -10. Add missing keymaps (quickfix navigation) -11. Enhance error handling - -### Phase 4: Polish (Nice to Have) -12. Add configuration validation -13. Enhance statusline -14. Add plugin documentation -15. Improve project root detection - ---- - -## ๐Ÿ“ Notes - -- Most issues are low-priority and don't affect functionality -- Configuration is generally well-organized -- Keymap conflicts are the main concern -- Documentation could be more comprehensive -- Performance optimizations are minor but worthwhile - ---- - -## ๐Ÿ”„ Maintenance Recommendations - -1. **Regular Audits:** Review keymaps quarterly for conflicts -2. **Plugin Updates:** Keep plugins updated but test before updating -3. **Documentation:** Update docs when adding new features -4. **Code Cleanup:** Remove commented code during refactoring -5. **Testing:** Test configuration after major changes - ---- - -**Last Updated:** 2024 -**Next Review:** Quarterly or after major changes diff --git a/LUA_CONFIGURATION_FIXES.md b/LUA_CONFIGURATION_FIXES.md deleted file mode 100644 index d375bf4..0000000 --- a/LUA_CONFIGURATION_FIXES.md +++ /dev/null @@ -1,159 +0,0 @@ -# Lua Configuration Fixes and Improvements - -## Issues Identified and Fixed - -### 1. **Snacks.nvim Configuration Issues** โœ… FIXED -- **Problem**: Setup not called, lazy loading issues, missing priority -- **Solution**: - - Added `lazy = false` and `priority = 1000` to snacks.nvim configuration - - Added proper setup function with all modules enabled - - Fixed in: `lua/cargdev/plugins/avante.lua` - -### 2. **Lua Version Compatibility** โœ… FIXED -- **Problem**: LuaRocks expects Lua 5.1 but found Lua 5.4.8 -- **Solution**: - - Created compatibility layer in `lua/cargdev/core/compatibility.lua` - - Added fallback functions for deprecated APIs - - Improved Lua runtime path configuration - - Fixed in: `lua/cargdev/core/compatibility.lua` - -### 3. **Deprecated API Warnings** โœ… FIXED -- **Problem**: Multiple deprecated API warnings from plugins -- **Solution**: - - Added `vim.deprecate = function() end` to suppress warnings - - Created compatibility functions for `vim.hl`, `vim.validate`, `vim.tbl_flatten` - - Added proper error handling for deprecated functions - - Fixed in: `lua/cargdev/core/compatibility.lua` - -### 4. **Keymap Conflicts** โœ… FIXED -- **Problem**: Multiple overlapping keymaps causing conflicts -- **Solution**: - - Reorganized keymaps with proper conflict resolution - - Added descriptive labels for all keymaps - - Separated conflicting mappings with different prefixes - - Fixed in: `lua/cargdev/core/keymaps.lua` - -### 5. **Missing Dependencies** โœ… FIXED -- **Problem**: `latex2text` not installed for render-markdown -- **Solution**: - - Disabled latex support in render-markdown configuration - - Added `latex = { enabled = false }` to avoid warning - - Fixed in: `lua/cargdev/plugins/avante.lua` - -### 6. **Core Options Improvements** โœ… ENHANCED -- **Problem**: Basic options configuration -- **Solution**: - - Enhanced options with modern Neovim best practices - - Added performance optimizations - - Improved UI settings and file handling - - Fixed in: `lua/cargdev/core/options.lua` - -## Files Modified - -### 1. `lua/cargdev/plugins/avante.lua` -- Fixed snacks.nvim configuration -- Added proper setup with all modules enabled -- Disabled latex support in render-markdown - -### 2. `lua/cargdev/core/compatibility.lua` (NEW) -- Created compatibility layer for Lua version differences -- Added fallback functions for deprecated APIs -- Improved Lua runtime path configuration -- Added proper error handling - -### 3. `lua/cargdev/core/options.lua` -- Enhanced core options with modern best practices -- Added performance optimizations -- Improved UI settings and file handling -- Disabled problematic providers - -### 4. `lua/cargdev/core/keymaps.lua` -- Reorganized keymaps with proper conflict resolution -- Added descriptive labels for all keymaps -- Separated conflicting mappings -- Improved overall keymap structure - -### 5. `lua/cargdev/core/init.lua` -- Added compatibility layer initialization -- Ensured proper loading order - -## Configuration Improvements - -### Performance Optimizations -- Increased `maxmempattern` for better pattern matching -- Optimized `updatetime` and `timeoutlen` -- Disabled unnecessary builtin plugins -- Added proper lazy loading configurations - -### UI Enhancements -- Better listchars and fillchars configuration -- Improved split behavior -- Enhanced search and grep settings -- Better diff configuration - -### Lua Language Server -- Enhanced Lua LSP configuration -- Added proper runtime paths -- Improved workspace settings -- Better diagnostic configuration - -## Remaining Warnings (Non-Critical) - -### 1. **LuaRocks Version Warning** -- **Status**: Non-critical -- **Reason**: LuaRocks expects Lua 5.1 but system has Lua 5.4.8 -- **Impact**: No functional impact, just a version mismatch warning - -### 2. **Missing codecompanion.nvim** -- **Status**: Non-critical -- **Reason**: Optional dependency for mcphub.nvim -- **Impact**: No functional impact, mcphub works without it - -### 3. **Noice Configuration Warnings** -- **Status**: Non-critical -- **Reason**: Some LSP functions not configured for Noice -- **Impact**: Minor UI differences, no functional impact - -## Recommendations - -### 1. **Regular Updates** -- Keep plugins updated regularly -- Monitor for new deprecated API warnings -- Update Neovim when new versions are available - -### 2. **Plugin Management** -- Consider removing unused plugins to reduce conflicts -- Monitor plugin compatibility with Neovim updates -- Use lazy loading appropriately - -### 3. **Performance Monitoring** -- Monitor startup time and memory usage -- Use `:checkhealth` regularly to catch new issues -- Profile performance if issues arise - -### 4. **Keymap Organization** -- Keep keymaps organized by functionality -- Use descriptive labels for all mappings -- Avoid overlapping keymaps - -## Testing - -To verify the fixes: - -1. **Restart Neovim**: `:source %` or restart the application -2. **Run health check**: `:checkhealth` -3. **Test keymaps**: Verify all keymaps work as expected -4. **Check LSP**: Ensure Lua LSP works properly -5. **Test plugins**: Verify all plugins load correctly - -## Expected Results - -After applying these fixes: -- โœ… No more snacks.nvim setup errors -- โœ… Reduced deprecated API warnings -- โœ… Resolved keymap conflicts -- โœ… Better Lua language server support -- โœ… Improved overall performance -- โœ… Enhanced user experience - -The configuration should now be more stable, performant, and maintainable. \ No newline at end of file diff --git a/README.md b/README.md index 68f9a4f..2f05b10 100644 --- a/README.md +++ b/README.md @@ -1,119 +1,178 @@ # Neovim Configuration -> **๐Ÿ“‹ Documentation:** -> - **[IMPROVEMENTS.md](./IMPROVEMENTS.md)** - Comprehensive analysis of configuration improvements and recommendations -> - **[keyboard_mappings.md](./keyboard_mappings.md)** - Complete keymap reference -> - **[NATIVE_AUTO_WRAPPER_GUIDE.md](./NATIVE_AUTO_WRAPPER_GUIDE.md)** - Text wrapping configuration guide +A modern, fast, and well-organized Neovim configuration built with Lua. ---- +## Requirements -# Vim and Tmux Keymaps +- **Neovim**: 0.9+ (0.10+ recommended) +- **Git**: For plugin management +- **Node.js**: For LSP servers and tooling +- **ripgrep** (`rg`): For fast file searching +- **Python 3**: With `pynvim` package for Python support -## Tmux Keymaps +### Optional Dependencies -### General Settings -- **Enable mouse support**: `set -g mouse on` (Allows scrolling, selecting panes, resizing) -- **Set scrollback buffer**: `set -g history-limit 2000` -- **Copy selected text to clipboard**: `set-option -g set-clipboard on` -- **Use vi-style key bindings**: `setw -g mode-keys vi` +- **Pandoc**: For HTML to Markdown conversion +- **Prettier**: For code formatting +- **Stylua**: For Lua formatting -### Reload Configuration -- **Reload tmux config**: `prefix + r` (Reloads tmux configuration) +## Installation -### Pane Navigation -- **Move panes**: - - `Alt + Left` โ†’ Move left - - `Alt + Right` โ†’ Move right - - `Alt + Up` โ†’ Move up - - `Alt + Down` โ†’ Move down -- **Split panes**: - - `prefix + |` โ†’ Vertical split - - `prefix + -` โ†’ Horizontal split -- **Sync panes**: - - `prefix + y` โ†’ Enable pane synchronization - - `prefix + y` โ†’ Disable pane synchronization +```bash +# Backup existing config (if any) +mv ~/.config/nvim ~/.config/nvim.bak -### Status Bar and UI Enhancements -- **Battery and time status**: `set -g status-right '#{battery_status_bg} battery: #{battery_percentage}% | %Y-%m-%d %H:%M '` -- **Pane border colors**: - - Inactive: `set -g pane-border-style fg=colour240` - - Active: `set -g pane-active-border-style fg=colour33` +# Clone this configuration +git clone ~/.config/nvim -### Resize Panes -- **Resize using Ctrl + Option + Arrow keys (macOS friendly)**: - - `Ctrl + Option + Left` โ†’ Resize left - - `Ctrl + Option + Right` โ†’ Resize right - - `Ctrl + Option + Up` โ†’ Resize up - - `Ctrl + Option + Down` โ†’ Resize down +# Start Neovim (plugins will auto-install) +nvim +``` -## Vim Keymaps +## Structure -### File Management -- **Save file**: `space + w` -- **Save and close all files**: `space + x + a` -- **Close all files**: `space + q` -- **Reload Neovim config**: `space + s + o` -- **Clear search highlights**: `space + n + o` +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # Entry point +โ”œโ”€โ”€ lua/cargdev/ +โ”‚ โ”œโ”€โ”€ core/ +โ”‚ โ”‚ โ”œโ”€โ”€ init.lua # Core initialization +โ”‚ โ”‚ โ”œโ”€โ”€ options.lua # Neovim options +โ”‚ โ”‚ โ”œโ”€โ”€ keymaps/ # Keymap modules +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ init.lua # Keymap loader +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ general.lua # General keymaps +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ personal.lua # Personal workflow keymaps +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ plugins.lua # Plugin-specific keymaps +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ window.lua # Window management +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ lsp.lua # LSP keymaps +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ copilot.lua # Copilot keymaps +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ... +โ”‚ โ”‚ โ””โ”€โ”€ function/ # Custom functions +โ”‚ โ”œโ”€โ”€ plugins/ # Plugin configurations +โ”‚ โ”‚ โ”œโ”€โ”€ lsp/ # LSP-related plugins +โ”‚ โ”‚ โ””โ”€โ”€ ... +โ”‚ โ””โ”€โ”€ lazy.lua # Lazy.nvim setup +โ””โ”€โ”€ ftplugin/ # Filetype-specific settings +``` -### Number Increment/Decrement -- **Increase number**: `space + +` -- **Decrease number**: `space + -` +## Key Features -### Window Management -- **Split window vertically**: `space + s + v` -- **Split window horizontally**: `space + s + h` -- **Make splits equal size**: `space + s + e` -- **Close split**: `space + s + x` +- **Plugin Manager**: [lazy.nvim](https://github.com/folke/lazy.nvim) with auto-update notifications +- **LSP**: Full LSP support with Mason for easy server management +- **Completion**: nvim-cmp with multiple sources +- **File Navigation**: Snacks.nvim (modern) + Telescope (git features) +- **File Explorer**: nvim-tree +- **Git Integration**: LazyGit, Gitsigns +- **AI Assistant**: GitHub Copilot with Copilot Chat +- **Debugging**: DAP with UI +- **Formatting**: Conform.nvim with auto-format on save +- **Diagnostics**: Trouble.nvim for organized diagnostics view -### Tabs -- **Open new tab**: `space + t + o` -- **Close tab**: `space + t + x` -- **Next tab**: `space + t + n` -- **Previous tab**: `space + t + p` -- **Move current buffer to new tab**: `space + t + f` +## Documentation -### Syntax Formatting -- **Format current file**: `space + s + y` +| Document | Description | +|----------|-------------| +| [CHANGELOG.md](./CHANGELOG.md) | Version history and changes | +| [keyboard_mappings.md](./keyboard_mappings.md) | QMK keyboard configuration | +| [NATIVE_AUTO_WRAPPER_GUIDE.md](./NATIVE_AUTO_WRAPPER_GUIDE.md) | Text wrapping configuration | +| [TELESCOPE_TO_SNACKS_MIGRATION.md](./TELESCOPE_TO_SNACKS_MIGRATION.md) | Migration notes | -### Buffer Management -- **Close current buffer**: `space + b + d` +## Quick Reference - Essential Keymaps + +### Leader Key: `` + +### File Operations +| Keymap | Description | +|--------|-------------| +| `w` | Save file | +| `q` | Close file | +| `xa` | Save and close all | +| `bd` | Close buffer (safe) | +| `bD` | Force close buffer | ### Navigation -- **Next buffer**: `Ctrl + p` -- **Previous buffer**: `Ctrl + n` +| Keymap | Description | +|--------|-------------| +| `ff` | Find files | +| `fs` | Live grep (search text) | +| `fr` | Recent files | +| `fb` | Find buffers | +| `e` | Toggle file explorer | -### Coding Enhancements -- **Add import React**: `space + r + e` -- **Add comma at end of line**: `space + ,` -- **Add semicolon at end of line**: `space + ;` -- **Insert console.log() below**: `space + c + o + n` -- **Run current file with Node.js**: `space + x` +### Window Management +| Keymap | Description | +|--------|-------------| +| `sv` | Split vertical | +| `sh` | Split horizontal | +| `se` | Equal splits | +| `sx` | Close split | +| `` | Resize splits | -### Resize Splits -- **Decrease vertical split**: `Ctrl + l` -- **Increase vertical split**: `Ctrl + h` -- **Increase horizontal split**: `Ctrl + k` -- **Decrease horizontal split**: `Ctrl + j` +### LSP +| Keymap | Description | +|--------|-------------| +| `gd` | Go to definition | +| `gr` | Show references | +| `K` | Hover documentation | +| `ca` | Code actions | +| `rn` | Rename symbol | +| `f` | Format buffer | +| `mm` | Format (conform) | -### LSP and Navigation -- **Show references**: `g + R` -- **Go to declaration**: `g + D` -- **Show definitions**: `g + d` -- **Show implementations**: `g + i` -- **Show type definitions**: `g + t` -- **See available code actions**: `space + c + a` -- **Rename variable**: `space + r + n` -- **Show buffer diagnostics**: `space + D` -- **Show line diagnostics**: `space + d` -- **Previous diagnostic**: `[ + d` -- **Next diagnostic**: `] + d` -- **Show documentation for cursor**: `K` -- **Restart LSP**: `space + r + s` +### Git +| Keymap | Description | +|--------|-------------| +| `gg` | LazyGit | +| `gs` | Git status | +| `gb` | Git blame | -### File Explorer (Nvim-Tree) -- **Toggle file explorer**: `space + e + e` -- **Toggle explorer on current file**: `space + n + t` -- **Collapse explorer**: `space + e + c` -- **Refresh explorer**: `space + e + r` +### Diagnostics & Quickfix +| Keymap | Description | +|--------|-------------| +| `xx` | Toggle Trouble | +| `xd` | Document diagnostics | +| `qn/qp` | Next/prev quickfix | +| `qo/qq` | Open/close quickfix | -This README provides an organized list of Vim and Tmux keymaps for efficient navigation and workflow. +### Session +| Keymap | Description | +|--------|-------------| +| `sS` | Save session | +| `sR` | Restore session | + +### Copilot +| Keymap | Description | +|--------|-------------| +| `` | Accept suggestion | +| `zc` | Open Copilot Chat | +| `ze` | Explain code (visual) | +| `zf` | Fix code (visual) | + +## Commands + +| Command | Description | +|---------|-------------| +| `:Lazy` | Open plugin manager | +| `:Mason` | Open LSP server manager | +| `:checkhealth` | Run health checks | +| `:CheckConfig` | Run config validation | +| `:FormatToggle` | Toggle auto-format on save | + +## Troubleshooting + +### Check Configuration Health +```vim +:checkhealth +:CheckConfig +``` + +### Common Issues + +1. **Plugins not loading**: Run `:Lazy sync` +2. **LSP not working**: Run `:Mason` and install required servers +3. **Formatting not working**: Ensure formatters are installed (prettier, stylua, etc.) +4. **Slow startup**: Check `:Lazy profile` for slow plugins + +## License + +MIT License - Feel free to use and modify as needed. diff --git a/cleanup_deprecated_adapters.lua b/cleanup_deprecated_adapters.lua deleted file mode 100644 index 834d398..0000000 --- a/cleanup_deprecated_adapters.lua +++ /dev/null @@ -1,28 +0,0 @@ --- Cleanup script for deprecated debug adapters --- Run this in Neovim with :lua loadfile("cleanup_deprecated_adapters.lua")() - -local function cleanup_deprecated_adapters() - local mason_registry = require("mason-registry") - - -- List of deprecated adapters to remove - local deprecated_adapters = { - "node-debug2-adapter", - "chrome-debug-adapter" - } - - print("๐Ÿงน Cleaning up deprecated debug adapters...") - - for _, adapter in ipairs(deprecated_adapters) do - if mason_registry.is_installed(adapter) then - print("๐Ÿ—‘๏ธ Uninstalling " .. adapter) - mason_registry.uninstall(adapter) - else - print("โœ… " .. adapter .. " is not installed") - end - end - - print("โœจ Cleanup complete! Make sure to restart Neovim for changes to take effect.") -end - --- Run the cleanup -cleanup_deprecated_adapters() \ No newline at end of file diff --git a/kkk b/kkk deleted file mode 100644 index 1d725b2..0000000 --- a/kkk +++ /dev/null @@ -1,100 +0,0 @@ -return { - "nvim-tree/nvim-tree.lua", - dependencies = "nvim-tree/nvim-web-devicons", - config = function() - local nvimtree = require("nvim-tree") - - -- recommended settings from nvim-tree documentation - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - - nvimtree.setup({ - view = { - width = 35, - relativenumber = true, - }, - -- change folder arrow icons - renderer = { - indent_markers = { - enable = true, - }, - icons = { - glyphs = { - folder = { - arrow_closed = "๏ก", -- arrow when folder is closed - arrow_open = "๏ฃ", -- arrow when folder is open - }, - }, - }, - }, - -- disable window_picker for - -- explorer to work well with - -- window splits - actions = { - open_file = { - quit_on_open = true, - window_picker = { - enable = false, - }, - }, - }, - filters = { - custom = { ".DS_Store" }, - }, - git = { - ignore = false, - }, - on_attach = function(bufnr) -- Correct way to set keymaps - local api = require("nvim-tree.api") - local opts = { noremap = true, silent = true, nowait = true, buffer = bufnr } - - -- Open file in vertical split - vim.keymap.set("n", "s", api.node.open.vertical, opts) - - -- Open file in horizontal split - vim.keymap.set("n", "i", api.node.open.horizontal, opts) - - -- Open file in the current window - vim.keymap.set("n", "o", api.node.open.edit, opts) - -- File Management keybindings - vim.keymap.set("n", "a", function() -- Add a new file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.create() - end, opts) - - vim.keymap.set("n", "r", function() -- Rename file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.rename() - end, opts) - - vim.keymap.set("n", "d", function() -- Delete file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.remove() - end, opts) - - vim.keymap.set("n", "x", function() -- Cut (move) file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.cut() - end, opts) - - vim.keymap.set("n", "p", function() -- Paste file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.paste() - end, opts) - - vim.keymap.set("n", "y", function() -- Copy file - vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.copy() - end, opts) - end, - }) - - -- set keymaps - local keymap = vim.keymap -- for conciseness - - keymap.set("n", "ee", "NvimTreeToggle", { desc = "Toggle file explorer" }) -- toggle file explorer - keymap.set("n", "nt", "NvimTreeFindFileToggle", { desc = "Toggle file explorer on current file" }) -- toggle file explorer on current file - keymap.set("n", "ec", "NvimTreeCollapse", { desc = "Collapse file explorer" }) -- collapse file explorer - keymap.set("n", "er", "NvimTreeRefresh", { desc = "Refresh file explorer" }) -- refresh file explorer - end, -} diff --git a/lua/cargdev/core/init.lua b/lua/cargdev/core/init.lua index 947d43a..2f3183e 100644 --- a/lua/cargdev/core/init.lua +++ b/lua/cargdev/core/init.lua @@ -34,31 +34,80 @@ local function load_functions() end -- 4. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue) +-- Only run if filetype is not already detected to avoid redundant calls vim.api.nvim_create_autocmd("BufRead", { pattern = "*", callback = function() - vim.cmd("silent filetype detect") + if vim.bo.filetype == "" then + vim.cmd("silent filetype detect") + end end, }) --- 5. Load functions immediately -load_functions() - --- 6. Fallback: also try to load on VimEnter if LazyDone doesn't fire +-- 5. Load functions on VimEnter to ensure plugins are loaded first +-- Using a flag to prevent double-loading +local functions_loaded = false vim.api.nvim_create_autocmd("VimEnter", { callback = function() - -- Wait a bit for plugins to load - vim.defer_fn(function() - load_functions() - end, 200) + if not functions_loaded then + vim.defer_fn(function() + load_functions() + functions_loaded = true + end, 200) + end end, once = true, }) ---[[ vim.api.nvim_create_autocmd("BufReadPost", { - once = true, +-- 6. Diagnostic float on hover (show diagnostics when cursor holds) +vim.api.nvim_create_autocmd("CursorHold", { callback = function() - require("cargdev.core.project_config").bootstrap_config() - end + local opts = { + focusable = false, + close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, + border = "rounded", + source = "always", + prefix = " ", + scope = "cursor", + } + vim.diagnostic.open_float(nil, opts) + end, }) - ]] + +-- 7. Configuration validation on startup +local function validate_config() + local warnings = {} + + -- Check Neovim version (require 0.9+) + if vim.fn.has("nvim-0.9") == 0 then + table.insert(warnings, "Neovim 0.9+ is recommended for this configuration") + end + + -- Check for required executables + local required_executables = { "git", "rg", "node" } + for _, exe in ipairs(required_executables) do + if vim.fn.executable(exe) == 0 then + table.insert(warnings, string.format("'%s' not found in PATH", exe)) + end + end + + -- Display warnings if any + if #warnings > 0 then + vim.defer_fn(function() + for _, warning in ipairs(warnings) do + vim.notify("Config Warning: " .. warning, vim.log.levels.WARN) + end + end, 1000) + end +end + +-- Run validation on startup +vim.api.nvim_create_autocmd("VimEnter", { + callback = validate_config, + once = true, +}) + +-- 8. Custom health check command +vim.api.nvim_create_user_command("CheckConfig", function() + vim.cmd("checkhealth") +end, { desc = "Run Neovim health check" }) diff --git a/lua/cargdev/core/keymaps/general.lua b/lua/cargdev/core/keymaps/general.lua index dabbe15..aac0e23 100644 --- a/lua/cargdev/core/keymaps/general.lua +++ b/lua/cargdev/core/keymaps/general.lua @@ -11,14 +11,16 @@ local opts = { noremap = true, silent = true } -- "jj" is much less likely to appear in normal typing and won't interfere keymap.set("i", "jj", "", opts) -- Exit insert mode with jj keymap.set("n", "nh", ":nohl", opts) -- Clear search highlights --- Removed: keymap.set("n", "x", '"_x', opts) -- Delete character without copying into register --- This was causing single character deletions to not be copied to the default register -- Save and quit (additional) keymap.set("n", "Q", ":qa!", { desc = "Quit all" }) --- Put this in your init.lua +-- Obsidian vault path with validation local vault_path = vim.env.IDEA_DIR +if not vault_path or vault_path == "" then + -- Silently skip Obsidian link setup if IDEA_DIR is not configured + return +end diff --git a/lua/cargdev/core/keymaps/personal.lua b/lua/cargdev/core/keymaps/personal.lua index 8c4dabe..eaaf39e 100644 --- a/lua/cargdev/core/keymaps/personal.lua +++ b/lua/cargdev/core/keymaps/personal.lua @@ -25,17 +25,7 @@ keymap.set("n", "no", ":noh ", { desc = "Reset search a word" }) keymap.set("n", "+", "", { desc = "Increment number" }) -- increment keymap.set("n", "-", "", { desc = "Decrement number" }) -- decrement --- window management -keymap.set("n", "sv", "v", { desc = "Split window vertically" }) -- split window vertically -keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) -- split window horizontally -keymap.set("n", "se", "=", { desc = "Make splits equal size" }) -- make split windows equal width & height -keymap.set("n", "sx", "close", { desc = "Close current split" }) -- close current split window - -keymap.set("n", "to", "tabnew", { desc = "Open new tab" }) -- open new tab -keymap.set("n", "tx", "tabclose", { desc = "Close current tab" }) -- close current tab -keymap.set("n", "tn", "tabn", { desc = "Go to next tab" }) -- go to next tab -keymap.set("n", "tp", "tabp", { desc = "Go to previous tab" }) -- go to previous tab -keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer in new tab" }) -- move current buffer to new tab +-- Window management keymaps are centralized in lua/cargdev/core/keymaps/window.lua -- sintax fixer keymap.set("n", "sy", "gg=G", { desc = "Format current file" }) @@ -43,8 +33,26 @@ keymap.set("n", "sy", "gg=G", { desc = "Format current file" }) keymap.set("n", "", "10", { noremap = true, silent = true }) keymap.set("n", "", "10", { noremap = true, silent = true }) --- close current file on buffer -keymap.set("n", "bd", ":bd", { desc = "Close current file on buffer" }) +-- Buffer management with safe close (confirms if unsaved changes) +keymap.set("n", "bd", function() + if vim.bo.modified then + vim.ui.select({ "Save & Close", "Discard & Close", "Cancel" }, { + prompt = "Buffer has unsaved changes:", + }, function(choice) + if choice == "Save & Close" then + vim.cmd("w") + vim.cmd("bd") + elseif choice == "Discard & Close" then + vim.cmd("bd!") + end + end) + else + vim.cmd("bd") + end +end, { desc = "Buffer: Close (safe)" }) + +-- Force close buffer without confirmation +keymap.set("n", "bD", ":bd!", { desc = "Buffer: Force close" }) -- Set buftabline mappings keymap.set("n", "", ":bnext", { noremap = true, silent = true }) @@ -62,17 +70,7 @@ keymap.set("n", ";", "$a;", { desc = "Adding ';' at the end of the keymap.set("n", "con", "oconsole.log()0w$h", { desc = "Adding console.log() on the line below" }) keymap.set("n", "x", ":!node %", { desc = "Running current project using node" }) --- Move between Tmux and Neovim splits using Alt + Arrow keys --- keymap.set("n", "", ":TmuxNavigateLeft", { noremap = true, silent = true }) --- keymap.set("n", "", ":TmuxNavigateDown", { noremap = true, silent = true }) --- keymap.set("n", "", ":TmuxNavigateUp", { noremap = true, silent = true }) --- keymap.set("n", "", ":TmuxNavigateRight", { noremap = true, silent = true }) - --- Resize splits using Ctrl + Arrow keys -keymap.set("n", "", ":vertical resize -5", { noremap = true, silent = true }) -keymap.set("n", "", ":vertical resize +5", { noremap = true, silent = true }) -keymap.set("n", "", ":resize +5", { noremap = true, silent = true }) -keymap.set("n", "", ":resize -5", { noremap = true, silent = true }) +-- Resize splits keymaps are centralized in lua/cargdev/core/keymaps/window.lua -- Run and Debug Project keymap.set("n", "pr", ":RunProject", { desc = "Run Project" }) @@ -91,3 +89,20 @@ keymap.set("v", "zd", ":CopilotChatDocs", { desc = "Generate docs (C keymap.set("n", "p", function() vim.cmd("read !pbpaste -Prefer html | pandoc -f html -t gfm") end, { desc = "Paste HTML clipboard as Markdown" }) + +-- ============================================================================= +-- QUICKFIX NAVIGATION +-- ============================================================================= + +keymap.set("n", "qn", ":cnextzz", { desc = "Quickfix: Next item" }) +keymap.set("n", "qp", ":cprevzz", { desc = "Quickfix: Previous item" }) +keymap.set("n", "qo", ":copen", { desc = "Quickfix: Open list" }) +keymap.set("n", "qq", ":cclose", { desc = "Quickfix: Close list" }) +keymap.set("n", "qf", ":cfirstzz", { desc = "Quickfix: First item" }) +keymap.set("n", "ql", ":clastzz", { desc = "Quickfix: Last item" }) + +-- Location list navigation +keymap.set("n", "ln", ":lnextzz", { desc = "Location: Next item" }) +keymap.set("n", "lp", ":lprevzz", { desc = "Location: Previous item" }) +keymap.set("n", "lo", ":lopen", { desc = "Location: Open list" }) +keymap.set("n", "lq", ":lclose", { desc = "Location: Close list" }) diff --git a/lua/cargdev/core/keymaps/plugins.lua b/lua/cargdev/core/keymaps/plugins.lua index c9c30c7..6430445 100644 --- a/lua/cargdev/core/keymaps/plugins.lua +++ b/lua/cargdev/core/keymaps/plugins.lua @@ -42,17 +42,17 @@ keymap.set("n", "tf", "ToggleTerm direction=float", { desc = "T keymap.set("n", "th", "ToggleTerm size=10 direction=horizontal", { desc = "ToggleTerm horizontal split" }) keymap.set("n", "tv", "ToggleTerm size=80 direction=vertical", { desc = "ToggleTerm vertical split" }) --- Session management -keymap.set("n", "ss", "SessionSave", { desc = "Save session" }) -keymap.set("n", "sr", "SessionRestore", { desc = "Restore session" }) +-- Session management (using sS and sR to avoid conflicts with substitute) +keymap.set("n", "sS", "SessionSave", { desc = "Session: Save" }) +keymap.set("n", "sR", "SessionRestore", { desc = "Session: Restore" }) -- Formatting keymap.set("n", "f", "lua vim.lsp.buf.format()", { desc = "Format buffer" }) --- Substitute (changed from s to sub to avoid conflicts) -keymap.set("n", "sub", "lua require('substitute').operator()", { desc = "Substitute with motion" }) -keymap.set("n", "ss", "lua require('substitute').line()", { desc = "Substitute line" }) -keymap.set("n", "S", "lua require('substitute').eol()", { desc = "Substitute to end of line" }) +-- Substitute +keymap.set("n", "sub", "lua require('substitute').operator()", { desc = "Substitute: With motion" }) +keymap.set("n", "sl", "lua require('substitute').line()", { desc = "Substitute: Line" }) +keymap.set("n", "S", "lua require('substitute').eol()", { desc = "Substitute: To end of line" }) -- Surround keymap.set("n", "sa", "lua require('nvim-surround').surround_add()", { desc = "Add surrounding" }) diff --git a/lua/cargdev/core/options.lua b/lua/cargdev/core/options.lua index 17c376e..4cba0f8 100644 --- a/lua/cargdev/core/options.lua +++ b/lua/cargdev/core/options.lua @@ -40,7 +40,7 @@ opt.smartindent = true -- Smart indent opt.updatetime = 100 -- Faster completion (reduced from 250) opt.timeoutlen = 200 -- Faster key sequence completion (reduced from 300) opt.redrawtime = 1500 -- Allow more time for loading syntax -opt.synmaxcol = 240 -- Only highlight the first 240 columns +opt.synmaxcol = 200 -- Only highlight the first 200 columns (conservative for performance) opt.maxmempattern = 1000 -- Reduce memory for pattern matching opt.hidden = true -- Allow switching buffers without saving opt.scrolljump = 1 -- Minimal number of screen lines to scroll @@ -49,9 +49,7 @@ opt.sidescrolloff = 3 -- Keep 3 columns left/right of cursor (reduced from 8) -- Syntax loading optimizations opt.syntax = "on" -- Enable syntax highlighting -opt.synmaxcol = 200 -- Reduce syntax highlighting column limit opt.lazyredraw = false -- Don't use lazy redraw (can cause issues) -opt.foldmethod = "syntax" -- Use syntax-based folding for better performance opt.foldlevel = 99 -- Don't fold by default -- Filetype plugin optimizations @@ -101,9 +99,8 @@ opt.formatoptions:append("j") -- Remove comment leader when joining lines opt.showmatch = true -- Show matching brackets opt.matchtime = 2 -- How long to show matching brackets --- Folding +-- Folding (indent-based is generally faster than syntax-based) opt.foldmethod = "indent" -- Fold based on indentation -opt.foldlevel = 99 -- Don't fold by default opt.foldnestmax = 10 -- Maximum nesting level -- Backup and swap diff --git a/lua/cargdev/lazy.lua b/lua/cargdev/lazy.lua index 7c99456..2ff1529 100644 --- a/lua/cargdev/lazy.lua +++ b/lua/cargdev/lazy.lua @@ -14,7 +14,8 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ { import = "cargdev.plugins" }, { import = "cargdev.plugins.lsp" } }, { checker = { enabled = true, - notify = false, + notify = true, -- Enable plugin update notifications + frequency = 86400, -- Check once per day (in seconds) }, change_detection = { notify = false, diff --git a/lua/cargdev/plugins/formatting.lua b/lua/cargdev/plugins/formatting.lua index dad4926..f05979c 100644 --- a/lua/cargdev/plugins/formatting.lua +++ b/lua/cargdev/plugins/formatting.lua @@ -32,7 +32,22 @@ return { dbml = { "dbml" }, -- DBML formatting sql = { "sqlfluff" }, -- SQL formatting }, - format_on_save = false, -- Set to true if you want auto-formatting on save + format_on_save = function(bufnr) + -- Disable autoformat for certain filetypes + local ignore_filetypes = { "sql", "markdown" } + if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then + return + end + -- Disable for files in certain paths + local bufname = vim.api.nvim_buf_get_name(bufnr) + if bufname:match("/node_modules/") then + return + end + return { + timeout_ms = 2000, + lsp_fallback = true, + } + end, }) vim.keymap.set({ "n", "v" }, "mm", function() @@ -41,6 +56,16 @@ return { async = false, timeout_ms = 2000, }) - end, { desc = "Format file or range (in visual mode)" }) + end, { desc = "Format: File or range (in visual mode)" }) + + -- Toggle auto-format on save + vim.api.nvim_create_user_command("FormatToggle", function() + vim.g.disable_autoformat = not vim.g.disable_autoformat + if vim.g.disable_autoformat then + vim.notify("Auto-format on save disabled", vim.log.levels.INFO) + else + vim.notify("Auto-format on save enabled", vim.log.levels.INFO) + end + end, { desc = "Toggle auto-format on save" }) end, } diff --git a/lua/cargdev/plugins/lualine.lua b/lua/cargdev/plugins/lualine.lua index 0c3ecee..14657f7 100644 --- a/lua/cargdev/plugins/lualine.lua +++ b/lua/cargdev/plugins/lualine.lua @@ -49,7 +49,7 @@ return { }, } - -- Custom word/character counter function + -- Custom word counter function local function word_count() -- Skip for very large files to avoid performance issues local line_count = vim.api.nvim_buf_line_count(0) @@ -58,7 +58,6 @@ return { end local words = 0 - local chars = 0 -- Get all lines at once for better performance local all_lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) @@ -69,13 +68,11 @@ return { for _ in line:gmatch("%S+") do words = words + 1 end - -- Count characters (excluding newline) - chars = chars + #line end end - -- Format: show words and characters - return string.format("%d words, %d chars", words, chars) + -- Format: show only word count + return string.format("%d words", words) end -- configure lualine with modified theme diff --git a/lua/cargdev/plugins/which-key.lua b/lua/cargdev/plugins/which-key.lua index bf868ec..e9929a9 100644 --- a/lua/cargdev/plugins/which-key.lua +++ b/lua/cargdev/plugins/which-key.lua @@ -5,9 +5,38 @@ return { vim.o.timeout = true vim.o.timeoutlen = 200 -- Reduced from 500 for faster response end, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, + config = function() + local wk = require("which-key") + + wk.setup({ + plugins = { + marks = true, + registers = true, + spelling = { enabled = true, suggestions = 20 }, + }, + win = { + border = "rounded", + padding = { 2, 2, 2, 2 }, + }, + }) + + -- Register group names for better organization + wk.add({ + { "b", group = "Buffer" }, + { "c", group = "Code/Copilot" }, + { "d", group = "Debug/DAP" }, + { "e", group = "Explorer" }, + { "f", group = "Find/Files" }, + { "g", group = "Git" }, + { "l", group = "LSP/LeetCode" }, + { "m", group = "Format" }, + { "n", group = "Notifications" }, + { "p", group = "Project" }, + { "q", group = "Quickfix" }, + { "s", group = "Session/Split/Substitute" }, + { "t", group = "Tab/Terminal/Text" }, + { "x", group = "Trouble/Diagnostics" }, + { "z", group = "Copilot Chat" }, + }) + end, }