Fix keymap conflicts and add improvements
- Fix duplicate git conflict keymaps (centralized in gitconflict.lua) - Fix duplicate Copilot keymaps (centralized in copilot.lua) - Change insert mode escape from 'jk' to 'jj' to avoid typing conflicts - Add word counter to statusline (lualine) - Disable Copilot by default for .tex files - Remove textwidth limits for visual wrapping based on window width - Add comprehensive improvements documentation (IMPROVEMENTS.md) - Update README with links to documentation
This commit is contained in:
644
IMPROVEMENTS.md
Normal file
644
IMPROVEMENTS.md
Normal file
@@ -0,0 +1,644 @@
|
|||||||
|
# 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:** `<leader>cp` was mapped in both files. Also had conflict with `<leader>ce` (enable vs explain).
|
||||||
|
|
||||||
|
**Resolution:**
|
||||||
|
- Removed duplicate `<leader>cp` from `personal.lua`
|
||||||
|
- Removed conflicting `<leader>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 (`<leader>sv`, `<leader>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`: `<leader>ss` = SessionSave
|
||||||
|
- `personal.lua`: `<leader>so` = Reload nvim (source %)
|
||||||
|
|
||||||
|
**Note:** These don't conflict directly, but `<leader>ss` conflicts with Substitute line in `plugins.lua` line 54.
|
||||||
|
|
||||||
|
**Recommendation:**
|
||||||
|
```lua
|
||||||
|
-- Rename session save/restore to avoid confusion:
|
||||||
|
-- <leader>sS = SessionSave
|
||||||
|
-- <leader>sR = SessionRestore
|
||||||
|
-- Or use a dedicated prefix: <leader>se (session)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Priority:** 🟡 Medium
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. **Substitute Keymap Already Conflicts**
|
||||||
|
**Location:** `lua/cargdev/core/keymaps/plugins.lua` line 54
|
||||||
|
|
||||||
|
**Issue:** `<leader>ss` is used for both SessionSave and Substitute line.
|
||||||
|
|
||||||
|
**Current State:** Comment says "changed from <leader>s to <leader>sub to avoid conflicts" but `<leader>ss` still conflicts.
|
||||||
|
|
||||||
|
**Recommendation:**
|
||||||
|
```lua
|
||||||
|
-- Use <leader>subs for substitute line
|
||||||
|
-- Keep <leader>ss for session save
|
||||||
|
-- Or use <leader>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", "<leader>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", "<leader>qn", ":cnext<CR>", { desc = "Next quickfix" })
|
||||||
|
keymap.set("n", "<leader>qp", ":cprev<CR>", { desc = "Previous quickfix" })
|
||||||
|
keymap.set("n", "<leader>qq", ":cclose<CR>", { 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
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# Vim and Tmux Keymaps
|
# Vim and Tmux Keymaps
|
||||||
|
|
||||||
## Tmux Keymaps
|
## Tmux Keymaps
|
||||||
|
|||||||
@@ -1,18 +1,86 @@
|
|||||||
-- Copilot keymaps
|
-- Copilot keymaps
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
|
|
||||||
|
-- Helper function to safely get Copilot modules
|
||||||
|
local function get_copilot_panel()
|
||||||
|
local ok, panel = pcall(require, "copilot.panel")
|
||||||
|
return ok and panel or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_copilot_suggestion()
|
||||||
|
local ok, suggestion = pcall(require, "copilot.suggestion")
|
||||||
|
return ok and suggestion or nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Copilot panel and status
|
-- Copilot panel and status
|
||||||
keymap.set("n", "<leader>cp", ":Copilot panel<CR>", { desc = "Copilot: Open copilot panel" })
|
keymap.set("n", "<leader>cp", ":Copilot panel<CR>", { desc = "Copilot: Open copilot panel" })
|
||||||
keymap.set("n", "<leader>cd", ":Copilot disable<CR>", { desc = "Copilot: Disable" })
|
keymap.set("n", "<leader>cd", ":Copilot disable<CR>", { desc = "Copilot: Disable" })
|
||||||
keymap.set("n", "<leader>ce", ":Copilot enable<CR>", { desc = "Copilot: Enable" })
|
keymap.set("n", "<leader>ce", ":Copilot enable<CR>", { desc = "Copilot: Enable" })
|
||||||
keymap.set("n", "<leader>cs", ":Copilot status<CR>", { desc = "Copilot: Status" })
|
keymap.set("n", "<leader>cs", ":Copilot status<CR>", { desc = "Copilot: Status" })
|
||||||
|
|
||||||
-- Copilot suggestion navigation (insert mode)
|
-- Copilot panel keymaps
|
||||||
-- These are configured in copilot.lua but documented here for reference:
|
keymap.set("n", "[[", function()
|
||||||
-- <leader>] - Next suggestion
|
local panel = get_copilot_panel()
|
||||||
-- <leader>[ - Previous suggestion
|
if panel and panel.is_open() then
|
||||||
-- <M-l> - Accept suggestion
|
panel.jump_prev()
|
||||||
-- <C-]> - Dismiss suggestion
|
end
|
||||||
|
end, { desc = "Copilot: Jump to previous suggestion in panel" })
|
||||||
|
|
||||||
|
keymap.set("n", "]]", function()
|
||||||
|
local panel = get_copilot_panel()
|
||||||
|
if panel and panel.is_open() then
|
||||||
|
panel.jump_next()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Jump to next suggestion in panel" })
|
||||||
|
|
||||||
|
keymap.set("n", "<CR>", function()
|
||||||
|
local panel = get_copilot_panel()
|
||||||
|
if panel and panel.is_open() then
|
||||||
|
panel.accept()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Accept suggestion in panel" })
|
||||||
|
|
||||||
|
keymap.set("n", "gr", function()
|
||||||
|
local panel = get_copilot_panel()
|
||||||
|
if panel and panel.is_open() then
|
||||||
|
panel.refresh()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Refresh panel" })
|
||||||
|
|
||||||
|
keymap.set("n", "<M-CR>", ":Copilot panel<CR>", { desc = "Copilot: Open panel" })
|
||||||
|
|
||||||
|
-- Copilot suggestion keymaps (insert mode)
|
||||||
|
keymap.set("i", "<Tab>", function()
|
||||||
|
local suggestion = get_copilot_suggestion()
|
||||||
|
if suggestion and suggestion.is_visible() then
|
||||||
|
suggestion.accept()
|
||||||
|
else
|
||||||
|
-- Feed Tab through so nvim-cmp can handle it for completion menu/snippets
|
||||||
|
-- Use 't' flag to avoid remapping, 'n' flag for normal mode keycodes
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "nt")
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Accept suggestion" })
|
||||||
|
|
||||||
|
keymap.set("i", "<leader>]", function()
|
||||||
|
local suggestion = get_copilot_suggestion()
|
||||||
|
if suggestion and suggestion.is_visible() then
|
||||||
|
suggestion.next()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Next suggestion" })
|
||||||
|
|
||||||
|
keymap.set("i", "<leader>[", function()
|
||||||
|
local suggestion = get_copilot_suggestion()
|
||||||
|
if suggestion and suggestion.is_visible() then
|
||||||
|
suggestion.prev()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Previous suggestion" })
|
||||||
|
|
||||||
|
keymap.set("i", "<C-]>", function()
|
||||||
|
local suggestion = get_copilot_suggestion()
|
||||||
|
if suggestion and suggestion.is_visible() then
|
||||||
|
suggestion.dismiss()
|
||||||
|
end
|
||||||
|
end, { desc = "Copilot: Dismiss suggestion" })
|
||||||
|
|
||||||
-- CodeCompanion keymaps
|
-- CodeCompanion keymaps
|
||||||
keymap.set("n", "<leader>cc", ":CodeCompanion<CR>", { desc = "CodeCompanion: Open CodeCompanion" })
|
keymap.set("n", "<leader>cc", ":CodeCompanion<CR>", { desc = "CodeCompanion: Open CodeCompanion" })
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ local opts = { noremap = true, silent = true }
|
|||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
-- General keymaps
|
-- General keymaps
|
||||||
keymap.set("i", "jk", "<ESC>", opts) -- Exit insert mode with jk
|
-- Changed from "jk" to "jj" to avoid conflicts when typing words containing 'j' followed by other letters
|
||||||
|
-- "jj" is much less likely to appear in normal typing and won't interfere
|
||||||
|
keymap.set("i", "jj", "<ESC>", opts) -- Exit insert mode with jj
|
||||||
keymap.set("n", "<leader>nh", ":nohl<CR>", opts) -- Clear search highlights
|
keymap.set("n", "<leader>nh", ":nohl<CR>", opts) -- Clear search highlights
|
||||||
keymap.set("n", "x", '"_x', opts) -- Delete character without copying into register
|
-- 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)
|
-- Save and quit (additional)
|
||||||
keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" })
|
keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" })
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local keymap = vim.keymap
|
|||||||
|
|
||||||
keymap.set("n", "]x", "<Plug>(git-conflict-next-conflict)", { desc = "Go to next git conflict" })
|
keymap.set("n", "]x", "<Plug>(git-conflict-next-conflict)", { desc = "Go to next git conflict" })
|
||||||
keymap.set("n", "[x", "<Plug>(git-conflict-prev-conflict)", { desc = "Go to previous git conflict" })
|
keymap.set("n", "[x", "<Plug>(git-conflict-prev-conflict)", { desc = "Go to previous git conflict" })
|
||||||
keymap.set("n", "<leader>coo", "<Plug>(git-conflict-ours)", { desc = "Choose ours (git conflict)" })
|
keymap.set("n", "<leader>co", "<Plug>(git-conflict-ours)", { desc = "Choose ours (git conflict)" })
|
||||||
keymap.set("n", "<leader>ct", "<Plug>(git-conflict-theirs)", { desc = "Choose theirs (git conflict)" })
|
keymap.set("n", "<leader>ct", "<Plug>(git-conflict-theirs)", { desc = "Choose theirs (git conflict)" })
|
||||||
keymap.set("n", "<leader>cb", "<Plug>(git-conflict-both)", { desc = "Choose both (git conflict)" })
|
keymap.set("n", "<leader>cb", "<Plug>(git-conflict-both)", { desc = "Choose both (git conflict)" })
|
||||||
keymap.set("n", "<leader>c0", "<Plug>(git-conflict-none)", { desc = "Choose none (git conflict)" })
|
keymap.set("n", "<leader>c0", "<Plug>(git-conflict-none)", { desc = "Choose none (git conflict)" })
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ keymap.set("n", "<C-j>", ":resize -5<CR>", { noremap = true, silent = true })
|
|||||||
keymap.set("n", "<leader>pr", ":RunProject<CR>", { desc = "Run Project" })
|
keymap.set("n", "<leader>pr", ":RunProject<CR>", { desc = "Run Project" })
|
||||||
keymap.set("n", "<leader>pd", ":DebugProject<CR>", { desc = "Debug Project" })
|
keymap.set("n", "<leader>pd", ":DebugProject<CR>", { desc = "Debug Project" })
|
||||||
|
|
||||||
-- Copilot Chat
|
-- Copilot Chat (all Copilot keymaps moved to lua/cargdev/core/keymaps/copilot.lua)
|
||||||
keymap.set("v", "<leader>zn", ":CopilotChatRename<CR>", { desc = "Rename variable (Copilot Chat)" })
|
keymap.set("v", "<leader>zn", ":CopilotChatRename<CR>", { desc = "Rename variable (Copilot Chat)" })
|
||||||
keymap.set("n", "<leader>zc", ":CopilotChat<CR>", { desc = "Open Copilot Chat" })
|
keymap.set("n", "<leader>zc", ":CopilotChat<CR>", { desc = "Open Copilot Chat" })
|
||||||
keymap.set("v", "<leader>ze", ":CopilotChatExplain<CR>", { desc = "Explain code (Copilot Chat)" })
|
keymap.set("v", "<leader>ze", ":CopilotChatExplain<CR>", { desc = "Explain code (Copilot Chat)" })
|
||||||
@@ -87,10 +87,6 @@ keymap.set("v", "<leader>zf", ":CopilotChatFix<CR>", { desc = "Fix code issues (
|
|||||||
keymap.set("v", "<leader>zo", ":CopilotChatOptimize<CR>", { desc = "Optimize code (Copilot Chat)" })
|
keymap.set("v", "<leader>zo", ":CopilotChatOptimize<CR>", { desc = "Optimize code (Copilot Chat)" })
|
||||||
keymap.set("v", "<leader>zd", ":CopilotChatDocs<CR>", { desc = "Generate docs (Copilot Chat)" })
|
keymap.set("v", "<leader>zd", ":CopilotChatDocs<CR>", { desc = "Generate docs (Copilot Chat)" })
|
||||||
|
|
||||||
-- Copilot
|
|
||||||
keymap.set("n", "<leader>cp", ":Copilot panel<CR>", { desc = "Copilot: Open copilot panel" })
|
|
||||||
keymap.set("n", "<leader>ce", ":CopilotChatExplain<CR>", { desc = "Copilot Chat: Explain code" })
|
|
||||||
|
|
||||||
-- Paste HTML as Markdown using pandoc
|
-- Paste HTML as Markdown using pandoc
|
||||||
keymap.set("n", "<leader>p", function()
|
keymap.set("n", "<leader>p", function()
|
||||||
vim.cmd("read !pbpaste -Prefer html | pandoc -f html -t gfm")
|
vim.cmd("read !pbpaste -Prefer html | pandoc -f html -t gfm")
|
||||||
|
|||||||
@@ -59,14 +59,7 @@ keymap.set("n", "<leader>sa", "<cmd>lua require('nvim-surround').surround_add()<
|
|||||||
keymap.set("n", "<leader>sd", "<cmd>lua require('nvim-surround').surround_delete()<cr>", { desc = "Delete surrounding" })
|
keymap.set("n", "<leader>sd", "<cmd>lua require('nvim-surround').surround_delete()<cr>", { desc = "Delete surrounding" })
|
||||||
keymap.set("n", "<leader>sr", "<cmd>lua require('nvim-surround').surround_replace()<cr>", { desc = "Replace surrounding" })
|
keymap.set("n", "<leader>sr", "<cmd>lua require('nvim-surround').surround_replace()<cr>", { desc = "Replace surrounding" })
|
||||||
|
|
||||||
-- Git conflicts
|
-- Git conflicts (moved to lua/cargdev/core/keymaps/gitconflict.lua)
|
||||||
keymap.set("n", "]x", "<Plug>(git-conflict-next-conflict)", { desc = "Go to next git conflict" })
|
|
||||||
keymap.set("n", "[x", "<Plug>(git-conflict-prev-conflict)", { desc = "Go to previous git conflict" })
|
|
||||||
keymap.set("n", "<leader>co", "<Plug>(git-conflict-ours)", { desc = "Choose ours (git conflict)" })
|
|
||||||
keymap.set("n", "<leader>ct", "<Plug>(git-conflict-theirs)", { desc = "Choose theirs (git conflict)" })
|
|
||||||
keymap.set("n", "<leader>cb", "<Plug>(git-conflict-both)", { desc = "Choose both (git conflict)" })
|
|
||||||
keymap.set("n", "<leader>c0", "<Plug>(git-conflict-none)", { desc = "Choose none (git conflict)" })
|
|
||||||
keymap.set("n", "<leader>cq", "<Plug>(git-conflict-list)", { desc = "List all git conflicts" })
|
|
||||||
|
|
||||||
-- LeetCode
|
-- LeetCode
|
||||||
keymap.set("n", "<leader>lr", "<cmd>Leet run<CR>", { desc = "LeetCode: Run Code" })
|
keymap.set("n", "<leader>lr", "<cmd>Leet run<CR>", { desc = "LeetCode: Run Code" })
|
||||||
|
|||||||
@@ -76,20 +76,20 @@ opt.signcolumn = "yes" -- Always show sign column
|
|||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
-- Text wrapping settings
|
-- Text wrapping settings
|
||||||
opt.wrap = true -- Enable line wrapping
|
opt.wrap = true -- Enable visual line wrapping (wraps based on window width)
|
||||||
opt.linebreak = true -- Break lines at word boundaries
|
opt.linebreak = true -- Break lines at word boundaries
|
||||||
opt.breakindent = true -- Preserve indentation in wrapped lines
|
opt.breakindent = true -- Preserve indentation in wrapped lines
|
||||||
opt.showbreak = "↪ " -- Show break indicator
|
opt.showbreak = "↪ " -- Show break indicator
|
||||||
opt.breakindentopt = "shift:2" -- Indent wrapped lines by 2 spaces
|
opt.breakindentopt = "shift:2" -- Indent wrapped lines by 2 spaces
|
||||||
|
|
||||||
-- Text width and formatting
|
-- Text width and formatting
|
||||||
opt.textwidth = 80 -- Set text width for auto-wrapping
|
opt.textwidth = 0 -- Disable hard wrapping (0 = no limit, wraps based on window width)
|
||||||
opt.colorcolumn = "80" -- Show column at 80 characters
|
opt.colorcolumn = "" -- Disable color column (or set to a high value if you want a guide)
|
||||||
opt.formatoptions = "jcroqlnt" -- Format options for auto-wrapping
|
opt.formatoptions = "jcroqln" -- Format options (removed 't' to disable auto-wrap based on textwidth)
|
||||||
|
|
||||||
-- Auto-wrap specific settings
|
-- Format options settings
|
||||||
opt.formatoptions:append("t") -- Auto-wrap text using textwidth
|
-- Note: 't' option removed - we want visual wrapping only, not hard line breaks
|
||||||
opt.formatoptions:append("c") -- Auto-wrap comments using textwidth
|
opt.formatoptions:append("c") -- Auto-wrap comments using textwidth (only applies if textwidth > 0)
|
||||||
opt.formatoptions:append("r") -- Auto-wrap comments when pressing Enter
|
opt.formatoptions:append("r") -- Auto-wrap comments when pressing Enter
|
||||||
opt.formatoptions:append("o") -- Auto-wrap comments when pressing 'o' or 'O'
|
opt.formatoptions:append("o") -- Auto-wrap comments when pressing 'o' or 'O'
|
||||||
opt.formatoptions:append("q") -- Allow formatting of comments with 'gq'
|
opt.formatoptions:append("q") -- Allow formatting of comments with 'gq'
|
||||||
@@ -214,33 +214,34 @@ end
|
|||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
-- Consolidated auto-wrapping configuration
|
-- Consolidated auto-wrapping configuration
|
||||||
|
-- Note: textwidth is set to 0 globally to allow visual wrapping based on window width
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function()
|
callback = function()
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
local opt = vim.opt_local
|
local opt = vim.opt_local
|
||||||
|
|
||||||
-- Text/documentation files
|
-- Text/documentation files - visual wrapping only (no hard breaks)
|
||||||
if vim.tbl_contains({ "text", "markdown", "gitcommit", "mail", "help", "man" }, filetype) then
|
if vim.tbl_contains({ "text", "markdown", "gitcommit", "mail", "help", "man" }, filetype) then
|
||||||
opt.textwidth = filetype == "help" or filetype == "man" and 78 or 80
|
opt.textwidth = 0 -- Disable hard wrapping, use visual wrapping based on window width
|
||||||
opt.wrap = true
|
opt.wrap = true
|
||||||
opt.linebreak = true
|
opt.linebreak = true
|
||||||
opt.formatoptions:append("t") -- Auto-wrap text
|
-- Removed 't' option - we want visual wrapping only, not hard line breaks
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Code files
|
-- Code files - visual wrapping only (no hard breaks)
|
||||||
if vim.tbl_contains({ "lua", "javascript", "typescript", "python", "java", "cpp", "c", "rust", "go" }, filetype) then
|
if vim.tbl_contains({ "lua", "javascript", "typescript", "python", "java", "cpp", "c", "rust", "go" }, filetype) then
|
||||||
opt.textwidth = 100 -- Longer lines for code
|
opt.textwidth = 0 -- Disable hard wrapping, use visual wrapping based on window width
|
||||||
opt.formatoptions:append("c") -- Auto-wrap comments
|
opt.formatoptions:append("c") -- Auto-wrap comments (only if textwidth > 0, so this won't apply)
|
||||||
opt.formatoptions:append("r") -- Auto-wrap comments with leader
|
opt.formatoptions:append("r") -- Auto-wrap comments with leader
|
||||||
opt.formatoptions:append("o") -- Auto-wrap comments with 'o'
|
opt.formatoptions:append("o") -- Auto-wrap comments with 'o'
|
||||||
opt.formatoptions:append("q") -- Allow formatting of comments with 'gq'
|
opt.formatoptions:append("q") -- Allow formatting of comments with 'gq'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Configuration files
|
-- Configuration files - visual wrapping only (no hard breaks)
|
||||||
if vim.tbl_contains({ "conf", "config", "ini", "toml", "yaml", "json" }, filetype) then
|
if vim.tbl_contains({ "conf", "config", "ini", "toml", "yaml", "json" }, filetype) then
|
||||||
opt.textwidth = 80
|
opt.textwidth = 0 -- Disable hard wrapping, use visual wrapping based on window width
|
||||||
opt.formatoptions:append("c") -- Auto-wrap comments
|
opt.formatoptions:append("c") -- Auto-wrap comments (only if textwidth > 0, so this won't apply)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,13 +8,6 @@ return {
|
|||||||
panel = {
|
panel = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
auto_refresh = false,
|
auto_refresh = false,
|
||||||
keymap = {
|
|
||||||
jump_prev = "[[",
|
|
||||||
jump_next = "]]",
|
|
||||||
accept = "<CR>",
|
|
||||||
refresh = "gr",
|
|
||||||
open = "<M-CR>",
|
|
||||||
},
|
|
||||||
layout = {
|
layout = {
|
||||||
position = "bottom", -- | top | left | right
|
position = "bottom", -- | top | left | right
|
||||||
ratio = 0.4,
|
ratio = 0.4,
|
||||||
@@ -24,14 +17,6 @@ return {
|
|||||||
enabled = true,
|
enabled = true,
|
||||||
auto_trigger = true, -- Enable auto-trigger suggestions as you type
|
auto_trigger = true, -- Enable auto-trigger suggestions as you type
|
||||||
debounce = 75,
|
debounce = 75,
|
||||||
keymap = {
|
|
||||||
accept = "<M-l>",
|
|
||||||
accept_word = false,
|
|
||||||
accept_line = false,
|
|
||||||
next = "<leader>]", -- Use leader key for next suggestion
|
|
||||||
prev = "<leader>[", -- Use leader key for previous suggestion
|
|
||||||
dismiss = "<C-]>",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
filetypes = {
|
filetypes = {
|
||||||
markdown = true,
|
markdown = true,
|
||||||
@@ -41,11 +26,27 @@ return {
|
|||||||
hgcommit = true,
|
hgcommit = true,
|
||||||
svn = true,
|
svn = true,
|
||||||
cvs = true,
|
cvs = true,
|
||||||
|
tex = false, -- Disable Copilot for LaTeX files by default
|
||||||
["."] = true,
|
["."] = true,
|
||||||
},
|
},
|
||||||
copilot_node_command = "node", -- Node.js version must be > 16.x
|
copilot_node_command = "node", -- Node.js version must be > 16.x
|
||||||
server_opts_overrides = {},
|
server_opts_overrides = {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Disable Copilot when opening .tex files
|
||||||
|
vim.api.nvim_create_autocmd({ "FileType", "BufEnter" }, {
|
||||||
|
pattern = "tex",
|
||||||
|
callback = function()
|
||||||
|
-- Safely dismiss any active suggestions
|
||||||
|
local ok, suggestion = pcall(require, "copilot.suggestion")
|
||||||
|
if ok and suggestion and suggestion.is_visible() then
|
||||||
|
suggestion.dismiss()
|
||||||
|
end
|
||||||
|
-- Disable Copilot for this buffer
|
||||||
|
vim.cmd("Copilot disable")
|
||||||
|
end,
|
||||||
|
desc = "Disable Copilot for LaTeX files",
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,12 +49,44 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Custom word/character 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)
|
||||||
|
if line_count > 10000 then
|
||||||
|
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)
|
||||||
|
|
||||||
|
for _, line in ipairs(all_lines) do
|
||||||
|
if line and #line > 0 then
|
||||||
|
-- Count words (non-whitespace sequences)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
-- configure lualine with modified theme
|
-- configure lualine with modified theme
|
||||||
lualine.setup({
|
lualine.setup({
|
||||||
options = {
|
options = {
|
||||||
theme = my_lualine_theme,
|
theme = my_lualine_theme,
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
lualine_a = { "mode" },
|
||||||
|
lualine_b = { "branch", "diff", "diagnostics" },
|
||||||
|
lualine_c = { "filename" },
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
{
|
{
|
||||||
lazy_status.updates,
|
lazy_status.updates,
|
||||||
@@ -65,6 +97,22 @@ return {
|
|||||||
{ "fileformat" },
|
{ "fileformat" },
|
||||||
{ "filetype" },
|
{ "filetype" },
|
||||||
},
|
},
|
||||||
|
lualine_y = { "progress" },
|
||||||
|
lualine_z = {
|
||||||
|
{
|
||||||
|
word_count,
|
||||||
|
color = { fg = colors.fg },
|
||||||
|
},
|
||||||
|
{ "location" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = { "filename" },
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = {},
|
||||||
|
lualine_x = {},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = { "location" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -47,17 +47,17 @@ return {
|
|||||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
-- Tab to accept Copilot suggestions, fallback to snippet expansion
|
-- Tab for completion menu and snippet expansion
|
||||||
|
-- Note: Copilot suggestion acceptance is handled in keymaps/copilot.lua
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
-- Handle nvim-cmp completion menu
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
local entry = cmp.get_selected_entry()
|
local entry = cmp.get_selected_entry()
|
||||||
-- If Copilot suggestion is available and selected, accept it
|
-- If Copilot suggestion is available and selected, accept it
|
||||||
if entry and entry.source.name == "copilot" then
|
if entry and entry.source.name == "copilot" then
|
||||||
cmp.confirm({ select = true })
|
cmp.confirm({ select = true })
|
||||||
else
|
else
|
||||||
-- Check if we can find a Copilot entry in the completion menu
|
-- Confirm the current selection
|
||||||
-- Since Copilot has high priority (900), it's likely near the top
|
|
||||||
-- Just confirm the current selection (Copilot will be selected if available)
|
|
||||||
cmp.confirm({ select = true })
|
cmp.confirm({ select = true })
|
||||||
end
|
end
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
|||||||
Reference in New Issue
Block a user