Skip to content

Convert from Lazy.nvim to vim.pack built-in package manager#6

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/update-init-lua-vim-pak
Draft

Convert from Lazy.nvim to vim.pack built-in package manager#6
Copilot wants to merge 5 commits intomainfrom
copilot/update-init-lua-vim-pak

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

Overview

This PR migrates BlindNvim from using Lazy.nvim as a plugin manager to Neovim's built-in package system (vim.pack). The change simplifies the codebase, removes external dependencies, and provides more direct control over plugin management while preserving all existing functionality.

Changes

Plugin Management System

Before (Lazy.nvim):

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({...})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  'user/plugin',
  {
    'plugin/with/config',
    config = function() ... end,
    dependencies = {...},
    build = "...",
  },
})

After (vim.pack):

local pack_path = vim.fn.stdpath("data") .. "/site/pack/plugins/start"

local function ensure_github_plugin(repo)
  local plugin_name = repo:match("^[^/]+/(.+)$")
  ensure_plugin("https://github.com/" .. repo .. ".git", plugin_name)
end

ensure_github_plugin('user/plugin')
ensure_github_plugin('plugin/with/config')

Key Features

  1. Automatic Plugin Installation

    • Plugins are automatically cloned to ~/.local/share/nvim/site/pack/plugins/start/ on first run
    • Uses shallow clones (--depth=1) for faster installation
    • Only clones plugins that don't already exist
  2. Build Step Automation

    • Automated compilation for plugins requiring build steps:
      • avante.nvim (make)
      • cmp-tabnine (./install.sh)
      • nvim-dbee (binary installation)
      • nvim-treesitter (TSUpdate - async)
      • fzf (fzf#install)
    • Uses vim.fn.jobstart() for safe, asynchronous execution
  3. Error Safety

    • All plugin configurations wrapped in pcall() to prevent initialization failures
    • Conditional loading based on VSCode mode preserved
    • Build failures logged without breaking startup
  4. Security & Performance

    • Fixed potential command injection vulnerability by using vim.fn.jobstart() with proper parameter handling
    • Async TSUpdate with configurable delay (1000ms) to prevent blocking startup
    • Named constants for better code maintainability

Benefits

No external dependencies - Uses only Neovim's built-in features
Simpler codebase - 321 insertions, 314 deletions (net +7 lines)
More transparent - Clear visibility of what plugins are installed and where
Better security - No third-party plugin manager code execution
Improved performance - Async operations for expensive tasks
Easier debugging - Direct control over plugin loading

Trade-offs

⚠️ No lazy loading - All plugins load at startup (can be added later if needed)
⚠️ Manual updates - Plugins need to be updated manually or via custom script
⚠️ No version pinning - Always uses latest from default branch
⚠️ Explicit dependencies - All plugin dependencies must be listed explicitly

Testing Recommendations

To test this PR:

  1. Fresh Installation Test

    # Remove existing plugins
    rm -rf ~/.local/share/nvim/site/pack/plugins
    
    # Launch Neovim and verify all plugins clone successfully
    nvim
  2. Functionality Test

    • Verify LSP works (mason, lspconfig)
    • Test completion (nvim-cmp)
    • Test Treesitter highlighting
    • Test Telescope
    • Test Git integration
  3. Build Steps Test

    • Check avante.nvim builds successfully
    • Check cmp-tabnine builds successfully
    • Verify Treesitter parsers update

Future Enhancements

Possible improvements that could be added later:

  • Plugin update automation script
  • Version pinning support
  • Selective lazy loading for heavy plugins
  • Health check command for plugin status

Files Changed

  • lua/plugins/init.lua - Complete rewrite to use vim.pack instead of Lazy.nvim

Fixes the issue by implementing a minimal, built-in package manager that leverages Neovim's native vim.pack system.

Original prompt

change init.lua in plugins folder to use vim.pak instead lazy package manager


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 4 commits October 18, 2025 10:05
Co-authored-by: JoTerrance <6041670+JoTerrance@users.noreply.github.com>
Co-authored-by: JoTerrance <6041670+JoTerrance@users.noreply.github.com>
Co-authored-by: JoTerrance <6041670+JoTerrance@users.noreply.github.com>
Co-authored-by: JoTerrance <6041670+JoTerrance@users.noreply.github.com>
Copilot AI changed the title [WIP] Change init.lua to use vim.pak instead of lazy package manager Convert from Lazy.nvim to vim.pack built-in package manager Oct 18, 2025
Copilot AI requested a review from JoTerrance October 18, 2025 10:13
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.

2 participants