Configs2026年5月14日·1 分钟阅读

lazy.nvim — Modern Plugin Manager for Neovim

A fast and feature-rich plugin manager for Neovim that handles lazy loading, lockfiles, profiling, and automatic builds with a clean Lua-based spec format.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
lazy.nvim Overview
通用 CLI 安装命令
npx tokrepo install ebd5fae6-4fb0-11f1-9bc6-00163e2b0d79

Introduction

lazy.nvim is the standard plugin manager for modern Neovim configurations. It replaces older tools like packer.nvim with a declarative Lua spec format, automatic lazy loading based on events, commands, keymaps, and filetypes, and a built-in UI for managing and profiling plugins.

What lazy.nvim Does

  • Installs, updates, and removes Neovim plugins from Git repositories and local paths
  • Lazy-loads plugins based on events, commands, keymaps, or filetypes automatically
  • Generates and maintains a lockfile (lazy-lock.json) for reproducible setups
  • Provides a built-in profiler showing startup time per plugin
  • Supports automatic post-install build steps (make, cargo, npm, etc.)

Architecture Overview

lazy.nvim stores plugins in a flat directory under stdpath("data")/lazy/. Each plugin spec is a Lua table declaring its source, dependencies, lazy-loading triggers, and configuration function. At startup, lazy.nvim reads the lockfile to verify versions, loads only the plugins whose triggers have fired, and defers the rest. The :Lazy UI provides a real-time view of plugin status, updates, and profiling data.

Self-Hosting & Configuration

  • Bootstrap lazy.nvim with the snippet above in your init.lua
  • Define plugin specs as Lua files in a plugins/ directory
  • Run :Lazy sync to install, update, and clean plugins in one step
  • Commit lazy-lock.json to version control for reproducible environments
  • Requires Neovim 0.8+ and Git

Key Features

  • Automatic lazy loading reduces startup to only the plugins you need at launch
  • Lockfile support pins exact commits for each plugin
  • Built-in profiler identifies slow plugins with per-plugin timing
  • Spec fragments let multiple files contribute to one plugin's configuration
  • Concurrency during install and update operations for fast package management

Comparison with Similar Tools

  • packer.nvim — predecessor using a compile step; lazy.nvim is faster and actively maintained
  • vim-plug — Vimscript-based, simpler; lazy.nvim offers richer Lua-native lazy loading
  • dein.vim — supports caching; lazy.nvim provides a more intuitive spec format and UI
  • mini.deps — minimalist approach; lazy.nvim has more features like profiling and lockfiles
  • rocks.nvim — uses luarocks for packaging; lazy.nvim manages Git-based plugin sources directly

FAQ

Q: How do I migrate from packer.nvim? A: Convert your use() calls to lazy.nvim spec tables. The format is similar but uses different keys (opts instead of config, event/cmd/keys for lazy loading).

Q: Can I pin a plugin to a specific version? A: Yes. Set the version field in the spec (e.g., version = "^2") or commit the lockfile for exact pins.

Q: How do I profile startup time? A: Run :Lazy profile to see a ranked list of plugins by load time.

Q: Does lazy.nvim support local plugins? A: Yes. Set dir to the local path instead of specifying a Git URL.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产