neovim-config

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LazyVim 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:
    editor/nvim/snippets/
    (friendly-snippets format)
  • 配置位置:
    editor/nvim/
  • 主题: Catppuccin Frappe(与终端、bat等保持一致)
  • 重点领域: 数据工作(dbt、SQL、Python)和Markdown编写
  • 代码片段:
    editor/nvim/snippets/
    (friendly-snippets格式)

Configuration Files

配置文件

FilePurpose
lua/plugins/*.lua
Plugin specifications (auto-loaded)
lua/config/keymaps.lua
Custom keybindings
lua/config/options.lua
Vim options
lua/config/autocmds.lua
Autocommands
lazy-lock.json
Plugin version lockfile
lazyvim.json
LazyVim extras configuration
文件用途
lua/plugins/*.lua
插件规格(自动加载)
lua/config/keymaps.lua
自定义按键绑定
lua/config/options.lua
Vim选项
lua/config/autocmds.lua
自动命令
lazy-lock.json
插件版本锁定文件
lazyvim.json
LazyVim扩展配置

Instructions

操作说明

Before Making Changes

修改前准备

  1. Check LazyVim defaults at https://www.lazyvim.org/ to avoid redundant configuration
  2. Read the existing config file before editing
  3. Verify the plugin is not already configured by LazyVim extras
  1. 查看LazyVim默认配置:https://www.lazyvim.org/,避免重复配置
  2. 编辑前先阅读现有配置文件
  3. 确认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 = true
lua
-- lua/config/options.lua
local opt = vim.opt

opt.relativenumber = false
opt.scrolloff = 8
opt.wrap = true

Autocmds 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

添加语言支持

  1. Check if LazyVim has an "extra" for the language (lazyvim.json)
  2. If yes, enable it rather than manual config
  3. If no, create
    lua/plugins/lang-<name>.lua
  1. 检查LazyVim是否有对应语言的“扩展”配置(lazyvim.json)
  2. 若有,直接启用而非手动配置
  3. 若无,创建
    lua/plugins/lang-<name>.lua
    文件

Add Snippets

添加代码片段

  1. Create JSON file in
    editor/nvim/snippets/<filetype>/<name>.json
  2. Follow friendly-snippets format
  3. Snippets auto-load for matching filetypes
  1. editor/nvim/snippets/<filetype>/<name>.json
    路径下创建JSON文件
  2. 遵循friendly-snippets格式
  3. 代码片段会自动为匹配的文件类型加载

Debug Configuration Issues

排查配置问题

  1. Run
    :checkhealth
    in Neovim
  2. Check
    :Lazy
    for plugin errors
  3. Use
    :verbose map <key>
    to trace keybindings
  4. Check
    :messages
    for startup errors
  1. 在Neovim中运行
    :checkhealth
  2. 查看
    :Lazy
    中的插件错误
  3. 使用
    :verbose map <按键>
    追踪按键绑定来源
  4. 查看
    :messages
    中的启动错误

Guidelines

指导原则

  • Prefer LazyVim extras over manual plugin config when available
  • Use
    opts
    table merging instead of full override when possible
  • Include
    desc
    for all keymaps (appears in which-key)
  • Lazy-load plugins with
    event
    ,
    ft
    ,
    cmd
    , or
    keys
  • 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
    表合并而非完全覆盖配置
  • 所有按键映射都要添加
    desc
    (会在which-key中显示)
  • 使用
    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
vim
. If you see "Undefined global
vim
" 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.
LazyVim使用LazyDev配置LuaLS(Lua语言服务器),使其识别额外类型和Neovim全局变量如
vim
。若你在Neovim插件配置文件中看到“Undefined global
vim
”警告,无需担心——LazyDev在编辑器实际的LSP服务器实例中包含了这些类型,但不会同步到bash环境中的LuaLS。

External Resources

外部资源