neovim-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLazyVim Configuration
LazyVim配置
LazyVim provides the base configuration for Neovim on this system, which is then customized to the user's needs and preferences. This skill works from this point of view, not a vanilla Neovim setup.
LazyVim为当前系统中的Neovim提供基础配置,之后可根据用户需求和偏好进行自定义。本技能基于此场景展开,而非原生Neovim配置。
Repository Context
仓库上下文
- Config location:
editor/nvim/ - Theme: Catppuccin Frappe (consistent with terminal, bat, etc.)
- Focus areas: Data work (dbt, SQL, Python) and Markdown authoring
- Snippets: (friendly-snippets format)
editor/nvim/snippets/
- 配置位置:
editor/nvim/ - 主题: Catppuccin Frappe(与终端、bat等保持一致)
- 重点领域: 数据工作(dbt、SQL、Python)和Markdown编写
- 代码片段: (friendly-snippets格式)
editor/nvim/snippets/
Configuration Files
配置文件
| File | Purpose |
|---|---|
| Plugin specifications (auto-loaded) |
| Custom keybindings |
| Vim options |
| Autocommands |
| Plugin version lockfile |
| LazyVim extras configuration |
| 文件 | 用途 |
|---|---|
| 插件规格(自动加载) |
| 自定义按键绑定 |
| Vim选项 |
| 自动命令 |
| 插件版本锁定文件 |
| LazyVim扩展配置 |
Instructions
操作说明
Before Making Changes
修改前准备
- Check LazyVim defaults at https://www.lazyvim.org/ to avoid redundant configuration
- Read the existing config file before editing
- Verify the plugin is not already configured by LazyVim extras
- 查看LazyVim默认配置:https://www.lazyvim.org/,避免重复配置
- 编辑前先阅读现有配置文件
- 确认LazyVim扩展未已配置该插件
Plugin Configuration
插件配置
Use LazyVim's plugin spec format, not raw lazy.nvim:
lua
-- lua/plugins/example.lua
return {
-- Extend existing plugin
{
"plugin/name",
opts = {
-- Options merge with defaults
},
},
-- Override existing plugin
{
"plugin/name",
opts = function(_, opts)
-- Modify opts table directly
opts.some_option = "value"
end,
},
-- Add new plugin
{
"author/new-plugin",
event = "VeryLazy", -- Lazy-load on event
dependencies = { "nvim-lua/plenary.nvim" },
opts = {},
keys = {
{ "<leader>xx", "<cmd>PluginCommand<cr>", desc = "Description" },
},
},
-- Disable a plugin
{ "plugin/to-disable", enabled = false },
}使用LazyVim的插件规格格式,而非原生lazy.nvim格式:
lua
-- lua/plugins/example.lua
return {
-- 扩展现有插件
{
"plugin/name",
opts = {
-- 选项与默认值合并
},
},
-- 覆盖现有插件
{
"plugin/name",
opts = function(_, opts)
-- 直接修改opts表
opts.some_option = "value"
end,
},
-- 添加新插件
{
"author/new-plugin",
event = "VeryLazy", -- 按事件延迟加载
dependencies = { "nvim-lua/plenary.nvim" },
opts = {},
keys = {
{ "<leader>xx", "<cmd>PluginCommand<cr>", desc = "描述" },
},
},
-- 禁用插件
{ "plugin/to-disable", enabled = false },
}Keymap Configuration
按键映射配置
lua
-- lua/config/keymaps.lua
local map = vim.keymap.set
-- Format: map(mode, lhs, rhs, opts)
map("n", "<leader>xx", "<cmd>SomeCommand<cr>", { desc = "Description" })
map("v", "<leader>yy", function() ... end, { desc = "Description" })
-- Delete a LazyVim keymap
vim.keymap.del("n", "<leader>existing")lua
-- lua/config/keymaps.lua
local map = vim.keymap.set
-- 格式: map(模式, 左侧按键, 右侧动作, 选项)
map("n", "<leader>xx", "<cmd>SomeCommand<cr>", { desc = "描述" })
map("v", "<leader>yy", function() ... end, { desc = "描述" })
-- 删除LazyVim默认按键映射
vim.keymap.del("n", "<leader>existing")Options Configuration
选项配置
lua
-- lua/config/options.lua
local opt = vim.opt
opt.relativenumber = false
opt.scrolloff = 8
opt.wrap = truelua
-- lua/config/options.lua
local opt = vim.opt
opt.relativenumber = false
opt.scrolloff = 8
opt.wrap = trueAutocmds Configuration
自动命令配置
lua
-- lua/config/autocmds.lua
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "python" },
callback = function()
vim.opt_local.tabstop = 4
end,
})lua
-- lua/config/autocmds.lua
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "python" },
callback = function()
vim.opt_local.tabstop = 4
end,
})Common Tasks
常见任务
Add Language Support
添加语言支持
- Check if LazyVim has an "extra" for the language (lazyvim.json)
- If yes, enable it rather than manual config
- If no, create
lua/plugins/lang-<name>.lua
- 检查LazyVim是否有对应语言的“扩展”配置(lazyvim.json)
- 若有,直接启用而非手动配置
- 若无,创建文件
lua/plugins/lang-<name>.lua
Add Snippets
添加代码片段
- Create JSON file in
editor/nvim/snippets/<filetype>/<name>.json - Follow friendly-snippets format
- Snippets auto-load for matching filetypes
- 在路径下创建JSON文件
editor/nvim/snippets/<filetype>/<name>.json - 遵循friendly-snippets格式
- 代码片段会自动为匹配的文件类型加载
Debug Configuration Issues
排查配置问题
- Run in Neovim
:checkhealth - Check for plugin errors
:Lazy - Use to trace keybindings
:verbose map <key> - Check for startup errors
:messages
- 在Neovim中运行
:checkhealth - 查看中的插件错误
:Lazy - 使用追踪按键绑定来源
:verbose map <按键> - 查看中的启动错误
:messages
Guidelines
指导原则
- Prefer LazyVim extras over manual plugin config when available
- Use table merging instead of full override when possible
opts - Include for all keymaps (appears in which-key)
desc - Lazy-load plugins with ,
event,ft, orcmdkeys - Test changes by restarting Neovim or running
:Lazy sync - Check for macOS keybinding conflicts (Mission Control, Spotlight)
- Keep Catppuccin Frappe theme consistent across colorscheme configs
- 优先使用LazyVim扩展而非手动配置插件
- 尽可能使用表合并而非完全覆盖配置
opts - 所有按键映射都要添加(会在which-key中显示)
desc - 使用、
event、ft或cmd延迟加载插件keys - 通过重启Neovim或运行测试修改
:Lazy sync - 检查macOS按键绑定冲突(如Mission Control、Spotlight)
- 保持Catppuccin Frappe主题在配色方案配置中的一致性
LuaLS Configuration and Warnings
LuaLS配置与警告
LazyVim use LazyDev to configure LuaLS (Lua Language Server) to recognize extra types and Neovim globals like . If you see "Undefined global " warnings in Neovim plugin config files, this is okay - LazyDev includes these types in the actual editor instance of the LSP server, but does not carry them over to your bash instance of LuaLS.
vimvimLazyVim使用LazyDev配置LuaLS(Lua语言服务器),使其识别额外类型和Neovim全局变量如。若你在Neovim插件配置文件中看到“Undefined global ”警告,无需担心——LazyDev在编辑器实际的LSP服务器实例中包含了这些类型,但不会同步到bash环境中的LuaLS。
vimvimExternal Resources
外部资源
- LazyVim Docs: https://www.lazyvim.org/
- For needs not covered here, refer to LazyVim documentation.
- LazyVim文档:https://www.lazyvim.org/
- 本文未覆盖的需求,请参考LazyVim官方文档。