# nvim_config **Repository Path**: hncjygd/nvim_config ## Basic Information - **Project Name**: nvim_config - **Description**: nvim 配置 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-15 - **Last Updated**: 2026-06-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Neovim 本配置基于[lazy.nvim](https://github.com/folke/lazy.nvim)插件管理器来自行构建。 ## 依赖安装 - snacks 插件依赖 - fd-find: 更好的 find 工具 - ripgrep: 更好的 grep 工具 - git: 代码管理工具 - lazygit: TUI git 管理工具 - Mason 插件依赖 - python3-venv: Python 的 venv 模块 - `3rd/image.nvim` 插件依赖 - kitty 终端 - imagemagick - MacOS: `brew install imagemagick` - Debian: `sudo apt install imagemagick` - curl: 远程图片 - Molten 插件依赖 - python3-pynvim: 直接通过包管理安装即可 - 在自己项目虚拟环境中安装 jupyter ## 配置文件结构 ``` . ├── init.lua ├── lazy-lock.json ├── lua │   ├── config │   │   ├── lazy.lua │   │   └── options.lua │   └── plugins │   ├── ai.lua │   ├── coding.lua │   ├── colorscheme.lua │   ├── core.lua │   ├── jupyter.lua │   ├── leap.lua │   ├── lsp.lua │   └── ui.lua └── readme.md ``` ## 使用指南 分模块介绍使用的插件以及对应的快捷键。 ### 核心插件 定义在 `plugins/core.lua` 下: - [folke/which-key.nvim](https://github.com/folke/which-key.nvim): 快捷键提示插件 - [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): treesitter - [nvim-neo-tree/neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim): 文件树 - [folke/snacks.nvim](https://github.com/folke/snacks.nvim): 一些常用的小工具,核心是 Picker 框架 - [rmagatti/auto-session](https://github.com/rmagatti/auto-session): 会话管理 - [s1n7ax/nvim-window-picker](https://github.com/s1n7ax/nvim-window-picker): Window 选择器 #### neo-tree 配置和快捷键 | 快捷键 | 说明 | | ------------ | -------------------- | | `e` | Toggle File Explorer | | `fe` | Toggle File Explorer | | `fs` | Save File | 在 neo-tree 窗口中可用的快捷键: | 快捷键 | 说明 | | ------ | ----------------------- | | l | open | | h | close_node | | s | open_split | | v | open_vsplit | | w | open_with_window_picker | | a | add | | A | add_directory | | d | delete | | r | rename | | y | copy_to_clipboard | | x | cut_to_clipboard | | p | paste_from_clipboard | | q | close_window | | Y | super_copy(UDF) | #### treesitter 配置和快捷键 treesitter 管理着语言的高亮、折叠和缩进,如果要添加新的语言支持需要添加到其中的 `ensure_installed` 数组中。 treesitter 并不提供快捷键不过他启用了 neovim 内置的折叠快捷键: | 快捷键 | 说明 | | ------ | ---------------------------- | | za | Toggle fold under cursor | | zA | Toggle All fold under cursor | | zc | Close fold under cursor | | zC | Close All fold under cursor | | zo | Open fold under cursor | | zO | Open All fold under cursor | | zm | Fold more | | zM | Close all folds | | zr | Fold less | | zR | Open all folds | #### Snacks 配置和快捷键 Snacks 提供了一些小工具,最为核心的就是提供了 Picker 框架,目前开启的包括: - bigfile: 超过 1.5M 的文件会禁止 LSP/Treesitter - indent: 提供折叠线 - input: 新的 input 窗口 - notifier - scope - scroll - bufdelete - picker: Picker 框架,这里主要是重绘了 vim.ui.select 的 UI - dashboard: Hello 面板 ##### Search/Find Snacks 的核心是 Picker 框架,因此所有的 search/Find 等都由 Snacks 提供: | 快捷键 | 说明 | | ------------ | ---------------------------- | | `fb` | Find Buffers | | `fc` | Find Config Files | | `ff` | Find Files | | `fg` | Find Git Files | | `fp` | Find Projects | | `fr` | Find Recent Files | | `sb` | Search Buffer Lines | | `sB` | Search Open Buffers | | `sg` | Grep | | `sw` | Search Word | | `ss` | Search LSP Symbols | | `sS` | Search LSP Workspace Symbols | 所有这些都会弹出一个 Picker 弹窗,它包含了一些快捷键(都是以 Ctrl + 字母的形式): | 快捷键 | 说明 | | -------------------- | ------------------- | | `` | Cancel | | `` | confirm | | `` | edit_split | | `` | edit_vsplit | | `//` | list_up | | `//` | list_down | | `` | preview_scroll_up | | `` | preview_scroll_down | ##### Toggle Snacks 提供了一些 Toggle 相关的快捷操作方式: | 快捷键 | 说明 | | ------------ | --------------- | | `ub` | Dark Backgroud | | `uc` | Conceallevel | | `ud` | Diagnostics | | `uD` | Dimming | | `ug` | Indent | | `uh` | Inlay Hints | | `ul` | Line Number | | `uL` | Relative Number | | `us` | Spelling | | `uT` | Treesitter | | `uw` | Warp | ##### Terminal Snacks 还提供了基础的 Terminal 支持,可以通过 `Snacks.terminal.toggle(command)` 来实现运行某个终端命令,因此最基本的打开终端的方法就是运行 zsh,还可以直接运行 lazygit 等: | 快捷键 | 说明 | | ------------ | --------------- | | `` | Toggle Terminal | | `gg` | Open Lazygit | #### auto-session 配置和快捷键 auto-session 项目包装了 vim 提供的 mksession 命令来管理会话: | 快捷键 | 说明 | | ------------ | ----------------------- | | `pd` | Delete Current Session | | `pD` | Delete Session | | `pl` | Load Session | | `ps` | Save Session | | `up` | Toggle AutoSave Session | #### nvim-window-picker 配置和快捷键 窗口相关,多数都是将内置的 C-w 切换到 `w`,比较特殊的是 `ww` 利用 nvim-window-picker 来可视化选择窗口: | 快捷键 | 说明 | | ------------------ | ------------------------------ | | `wh/j/k/l` | Goto Left/Down/Up/Right Window | | `ww` | Switch Window | | `wH/J/K/L` | MoveTo Left/Down/Up/Right | | `wd` | Delete Window | | `wo` | Close all other Windows | | `ws/v` | Split/Vsplit Window | | `w+/-` | Increase/Decrease Height | | `w>/<` | Increase/Decrease Width | | `w=` | Equally Height Width | | `wp` | Picker Window | ### LSP插件 定义在 `plugins/lsp.lua` 下: - [mason-org/mason-lspconfig.nvim](https://github.com/mason-org/mason-lspconfig.nvim): 沟通 mason 和 lspconfig - [mason-org/mason.nvim](https://github.com/mason-org/mason.nvim): 自动安装 LSP、Formatter、Linter、DAP 等工具 - [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig): Neovim 官方提供的 LSP 配置集合 - [stevearc/conform.nvim](https::/github.com/stevearc/conform.nvim): 格式化工具 - [WhoIsSethDaniel/mason-tool-installer.nvim](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim): 自动安装工具(使用 mason) - [saghen/blink.cmp](https://github.com/saghen/blink.cmp): 自动补全 - [rafamadriz/friendly-snippets](https://github.com/rafamadriz/friendly-snippets): snippets > 对于每一个语言都需要在 lsp.lua 中添加 lsp、格式化工具。通常还需要在 core.lua 中添加 treesitter 工具 #### LSP 相关快捷键 LSP 相关的快捷键定义在 Snacks 插件中: | 快捷键 | 说明 | | ------------ | --------------------- | | gd | Goto Definition | | gD | Goto Declaration | | gr | Goto References | | gI | Goto Implementation | | gy | Goto Type Definition | | gai | Calls Incoming | | gao | Calls Outgoing | | `ss` | LSP Symbols | | `sS` | LSP Workspace Symbols | #### 补全相关快捷键 补全由 blink.cmp 提供: | 快捷键 | 说明 | | -------------------- | ------------------------- | | `//` | select_prev | | `//` | select_next | | `` | scroll_documentation_up | | `` | scroll_documentation_down | | `` | show_signature | | `` | accept | | `` | show/toggle_documentation | | `` | hide | | `` | snippet_forward | | `` | snippet_backward | 这其中有两个比较特殊: - ``: 在没有补全菜单的时候弹出补全菜单(show),如果已经存在补全菜单了则切换显示文档 - ``: 并不会选择他仅仅是在片段的占位之间跳转 ### Coding 插件 定义在 `plugins/coding.lua` 下: - [nvim-mini/mini.nvim](https://github.com/nvim-mini/mini.nvim): 插件集合 - [HiPhish/rainbow-delimiters.nvim](https://github.com/HiPhish/rainbow-delimiters.nvim): 彩虹括号 - [jake-stewart/multicursor.nvim](https://github.com/jake-stewart/multicursor.nvim): 多光标编辑 - [MagicDuck/grug-far.nvim](https://github.com/MagicDuck/grug-far.nvim): 批量查找替换 - [ggandor/leap.nvim](https://github.com/ggandor/leap.nvim): EasyMotion 类插件 #### grug-far 查找替换 通过 `sr` 来打开一个新的缓冲区,其中会定义好几个设置项目: 1. Search: 要查找的字符串,支持正则表达式 2. Replace: 要替换为的字符串 3. Files Filter: 文件过滤,默认当前项目下的所有文件 4. Flags: 搜索替换标志 5. Paths: 要搜索的目录,默认当前项目 成功搜索后会在下方出现预览图,其中会显示位于的文件名称以及在文件中的行数,之后就需要执行替换操作了,他们都被绑定在 `` 前缀下: | 快捷键 | 说明 | | ---------------- | --------- | | `l` | Sync Line | | `s` | Sync All | | `n` | Sync Next | | `n` | Sync Prev | | `v` | Sync File | | `c` | Close | | Enter | Open File | #### leap.nvim 说明 他能够实现类似 EasyMotion 操作: - `s{char1}{char2}{?}`: 类似 sneak 那样两字符跳转,更进一步的是结合了 EasyMotion 能够通过两个字符来在整个 buffer 中跳转 - `f{char1}{?}`: 重构了默认的 f 命令,这个更像 sneak 了(只不过第二个字符是跳转字符) #### 多光标 多光标由 multicursor.nvim 插件提供支持: | 快捷键 | 说明 | | ----------------------------------------- | ------------------------ | | ``/`` | Add Cursor Line Up/Down | | ``/`` | Skip Cursor Line Up/Down | | `I/A`|Add Cursor Visual| | `n`|Add Cursor Next Match| | `N`|Skip Cursor Next Match| | `s`|Add Cursor Prev Match| | `S`|Skip Cursor Prev Match| | `A`|Add Cursor All Match| ### git git 管理由 lazygit 实现,细节的 hunk 管理由 `lewis6991/gitsigns.nvim` 插件实现: | 快捷键 | 说明 | | ------------ | ------------------- | | `gg` | Open Lazygit | | `gs` | Stage Hunk | | `gr` | Reset Hunk | | `gS` | Stage Buffer | | `gR` | Reset Buffer | | `gu` | Undo Stage Buffer | | `gp` | Preview Hunk Inline | | `gb` | Blame Line | | `gB` | Blame Buffer | | `gd` | Diff This | | `gD` | Diff This ~ |