Skip to content

Conversation

@rikuson
Copy link
Owner

@rikuson rikuson commented Nov 11, 2025

This commit implements several refactoring improvements to the Neovim configuration:

  1. Create constants module (lua/config/constants.lua)

    • Centralize all magic numbers (timer intervals, file size limits, priorities)
    • Make configuration values easy to find and modify
    • Self-documenting with descriptive names
  2. Fix easymotion timer memory leak

    • Replace recursive timer creation with single timer instance
    • Add proper timer cleanup on VimLeave
    • Use vim.uv instead of deprecated vim.loop
    • Remove global state dependency
  3. Eliminate global function pollution (toggleterm.lua)

    • Replace global _lazygit_toggle() and _lazydocker_toggle() functions
    • Use local module pattern with lazy initialization
    • Improve encapsulation and testability
  4. Consolidate duplicate Mason setup

    • Create dedicated mason.lua plugin file
    • Remove duplicate mason.setup() calls from nvim-lspconfig and none-ls
    • Prevent initialization race conditions
    • Use explicit dependencies
  5. Add comprehensive error handling

    • Create utility module (lua/config/utils.lua) with safe_require and safe_execute
    • Add error handling to mason, nvim-lspconfig, and none-ls plugins
    • Provide clear error notifications on failure
    • Graceful degradation when plugins fail to load

All changes are non-breaking and maintain existing functionality while improving:

  • Code maintainability
  • Error resilience
  • Performance (no timer leaks)
  • Code organization

This commit implements several refactoring improvements to the Neovim configuration:

1. **Create constants module** (lua/config/constants.lua)
   - Centralize all magic numbers (timer intervals, file size limits, priorities)
   - Make configuration values easy to find and modify
   - Self-documenting with descriptive names

2. **Fix easymotion timer memory leak**
   - Replace recursive timer creation with single timer instance
   - Add proper timer cleanup on VimLeave
   - Use vim.uv instead of deprecated vim.loop
   - Remove global state dependency

3. **Eliminate global function pollution** (toggleterm.lua)
   - Replace global _lazygit_toggle() and _lazydocker_toggle() functions
   - Use local module pattern with lazy initialization
   - Improve encapsulation and testability

4. **Consolidate duplicate Mason setup**
   - Create dedicated mason.lua plugin file
   - Remove duplicate mason.setup() calls from nvim-lspconfig and none-ls
   - Prevent initialization race conditions
   - Use explicit dependencies

5. **Add comprehensive error handling**
   - Create utility module (lua/config/utils.lua) with safe_require and safe_execute
   - Add error handling to mason, nvim-lspconfig, and none-ls plugins
   - Provide clear error notifications on failure
   - Graceful degradation when plugins fail to load

All changes are non-breaking and maintain existing functionality while improving:
- Code maintainability
- Error resilience
- Performance (no timer leaks)
- Code organization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants