# nvim **Repository Path**: codezm/nvim ## Basic Information - **Project Name**: nvim - **Description**: nvim配置 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-12-01 - **Last Updated**: 2025-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # [neovim](https://neovim.io/) 学习 - https://github.com/nvim-lua/kickstart.nvim | Normal | 功能 | |------------|--------------------------| | H | 切换至上一个buffer | | L | 切换至下一个buffer | | gf | 打开文件 | | gx | 打开URL | | zz | 当前行居中 | | zt | 当前行置顶 | | zb | 当前行置尾 | | nh | 取消检索高亮显示 | | bc | 关闭当前buffer | | gv | 选中最近一次visual文本块 | [[_toc_]] #### Requirements - git - ripgrep #### Vim Text Object #### 仅在某个项目目录生效 创建 `.nvim.lua` 文件 > 注意:.config/nvim/lua/options.lua 文件中,需开启 `options.exrc = true` 选项,以使 nvim 启用 `.nvim.lua` 配置文件。 #### 字体 [HackNerdFont-Regular](https://www.nerdfonts.com/font-downloads) #### KeyMaps `` 配置为空格。 #### [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | Normal | 功能 | | gd | 跳转至定义 | | gr | 跳转至引用 | | gi | 跳转至实现 | | rn | 重命名function,使用 [lspsaga](https://nvimdev.github.io/lspsaga/),关闭窗口 | | ca | 创建Action:添加缺失的docblocks、return type、依赖类等 | | fc | 格式化代码 | | da | 打开诊断器 | ##### [nvim-treesitter/nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) | Normal | 功能 | | (v/y/d)af | 选择/复制/删除函数体 | | (v/y/d)if | 选择/复制/删除函数体内容 | | (v/y/d)ac | 选择/复制/删除类体 | | (v/y/d)ic | 选择/复制/删除类体内容 | ##### [s1n7ax/nvim-window-picker](https://github.com/s1n7ax/nvim-window-picker) 这个插件提示用户选择一个窗口,并返回所选窗口的窗口id。 默认是通过`` + h、j、k、l 来切换窗口,通过此插件使用快捷键:`p` 将提示每个窗口的标识,键入标识切换至目标窗口。 ##### [echasnovski/mini.comment](https://github.com/echasnovski/mini.comment) | Normal/Visual | 功能 | | gcc/gc | 注释(反注释)当前行/注释视图模式下选中行 | ##### [echasnovski/mini.ai](https://github.com/echasnovski/mini.ai) 它增强了一些内置文本对象(如 a(、a)、a' 等),创建了一些新对象(如 a*、a、af、a? 等),并允许用户创建自己的对象(如基于 treesitter 的对象等)。 ##### [nvim-neo-tree/neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) Neo-tree 是一个 Neovim 插件,能以任何适合你的风格浏览文件系统和其他树状结构,包括侧边栏、浮动窗口、netrw 分割风格,或同时浏览所有这些风格! | Normal | 功能 | | e | 打开目录树 | | ? | 显示快捷键指令 | | H | 开启/关闭显示隐藏文件 | | . | 设为根目录 | | q | 关闭窗口 | | R | 刷新 | | t | 在新窗口中打开文件, 关闭Neo-tree | | s | 竖向拆分新窗口中打开文件 | | S | 横向拆分新窗口中打开文件 | | C | 关闭节点 | | z | 关闭所有节点 | | Z | 展开所有节点 | | A | 创建文件夹 | | a | 创建文件 | | r | 重命名文件 | | x | 剪切文件至粘贴板 | | y | 复制文件至粘贴板 | | p | 从粘贴板中粘贴文件 | | d | 删除文件 | ##### [ellisonleao/glow.nvim](https://github.com/ellisonleao/glow.nvim) 简单markdown预览插件,需安装 `glow` 软件:`brew install glow` 使用方式: ``` :Glow ``` ##### [folke/which-key.nvim](https://github.com/folke/which-key.nvim) 它显示一个弹出窗口,其中包含您开始键入的命令的可能的键绑定。 ##### [folke/persistence.nvim](https://github.com/folke/persistence.nvim) 自动会话管理工具,在退出时自动将会话保存在 `~/.local/state/nvim/sessions` 文件中。 | Normal | 功能 | |--------------------|------------------------------------------------------------------------------------| | `` + qs | 在当前目录中重新打开会话 | | `` + ql | 打开最后一次会话 | | `` + qd | 退出时会话将不会被保存| ##### [flash.nvim](https://github.com/folke/flash.nvim) | Normal | 功能 | |--------------------|------------------------------------------------------------------------------------| | f/F + <某个字母> | 向后/向前查找某个字母。再次使用 f 向前查找,使用 F 向后查找。默认查找下一个是 `;` 键 | | s + <某个字母> | 查找某个字母。再次按红色提示字母将实现光标跳转 | | S + <某个字母> | 结合 treesitter 实现单词、参数、行、代码块、方法体快速选择 | | y + r + <某个字母> | 实现复制某些内容,并调回到原光标位置 | | y + R + <某个字符> | 结合 treesitter 实现单词、参数、行、代码块、方法体复制,但不会回到原光标位置 | ##### [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) | 快捷键 | 功能 | |:---------------:|:------------------------------------------------------------------------------------------------------------:| | `` + ff | 在当前工作区中,根据文件名进行检索 | | `` + fg | 在当前工作区中,根据文件内容进行检索 | | `` + fh | 列出当前 neovim 实例中打开的缓冲区(Buffer) | | `` + fb | 打开文件浏览器 | | `` + fm | 检索书签(Marks)文件 | | `` + ft | 列出当前目录中的标签(Tags),并提供标签位置文件预览(用户需要运行 ctags -R 生成标签或在引入新更改时进行更新) | | `` + bf | 在当前文件中检索关键字 | ##### [telescope-file-browser.nvim](https://github.com/nvim-telescope/telescope-file-browser.nvim) | Insert / Normal | fb_actions | Description | | --------------- | -------------------- | -------------------------------------------------------------------------------- | | `/c` | create | Create file/folder at current `path` (trailing path separator creates folder) | | `` | create_from_prompt | Create and open file/folder from prompt (trailing path separator creates folder) | | `/r` | rename | Rename multi-selected files/folders | | `/m` | move | Move multi-selected files/folders to current `path` | | `/y` | copy | Copy (multi-)selected files/folders to current `path` | | `/d` | remove | Delete (multi-)selected files/folders | | `/o` | open | Open file/folder with default system application | | `/g` | goto_parent_dir | Go to parent directory | | `/e` | goto_home_dir | Go to home directory | | `/w` | goto_cwd | Go to current working directory (cwd) | | `/t` | change_cwd | Change nvim's cwd to selected folder/file(parent) | | `/f` | toggle_browser | Toggle between file and folder browser | | `/h` | toggle_hidden | Toggle hidden files/folders | | `/s` | toggle_all | Toggle all entries ignoring `./` and `../` | | `` | see `telescope.nvim` | Toggle selection and move to next selection | | `` | see `telescope.nvim` | Toggle selection and move to prev selection | | `/` | backspace | With an empty prompt, goes to parent dir. Otherwise acts normally | Placing custom signs !@#$%^&*() as visual markers##### [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim) | 快捷键 | 功能 | |:--------------:|:--------------------------:| | `` + r | 开启/关闭实时预览 MarkDown | ##### [vim-signature](https://github.com/kshenoy/vim-signature) | operate | description | |------------|---------------------------------------------------------------------------------------------| | mx | Toggle mark 'x' and display it in the leftmost column | | dmx | Remove mark 'x' where x is a-zA-Z | |------------|---------------------------------------------------------------------------------------------| | m, | Place the next available mark | | m. | If no mark on line, place the next available mark. Otherwise, remove (first) existing mark. | | m- | Delete all marks from the current line | | m | Delete all marks from the current buffer | | ]` | Jump to next mark | | [` | Jump to prev mark | | ]' | Jump to start of next line containing a mark | | [' | Jump to start of prev line containing a mark | | `] | Jump by alphabetical order to next mark | | `[ | Jump by alphabetical order to prev mark | | '] | Jump by alphabetical order to start of next line having a mark | | '[ | Jump by alphabetical order to start of prev line having a mark | | m/ | Open location list and display marks from current buffer | |------------|---------------------------------------------------------------------------------------------| | m[0-9] | Toggle the corresponding marker !@#$%^&*() | | m | Remove all markers of the same type | | ]- | Jump to next line having a marker of the same type | | [- | Jump to prev line having a marker of the same type | | ]= | Jump to next line having a marker of any type | | [= | Jump to prev line having a marker of any type | | m? | Open location list and display markers from current buffer | | m | Remove all markers | ##### [vim-table-mode](https://github.com/dhruvasagar/vim-table-mode) > v4.8.1 | 快捷键 | 功能 | |:-----------------------|:-----------------------------------------------------------------| | `` + t + m | 开启/关闭 Table Mode (以下快捷键只有开启时键入有效) | | `` + t + d + c | 删除光标所在的列 | | `` + t + i + c | 在光标所在列后新增一列 | | `` + t + i + C | 在光标所在列前新增一列 | | [ + \|、] + \| | 移动光标到上一个、下一个单元格 | | { + \|、} + \| | ~~移动光标到表格头、表格尾~~ | | `` + t + f + a | 录入公式(示例:Sum(1:-1) 求当前列从第1行至倒数第二行和) | | `` + t + f + e | 重新计算表格中所有列(公式)的结果值 | CSV 格式数据快速转成 Table: 普通模式下选中元素行依次输入 `:` + `Tableize` ###### Demo | Name | Age | Cost | |--------|-----|------:| | lisi | 23 | 330 | | wangwu | 22 | 310 | | Total | 45 | 640.0 | ### 参考 - [B站FledgeShiu](https://github.com/FledgeXu/NeovimZero2Hero) [NeoVim 从平凡到非凡合集](https://space.bilibili.com/747863/channel/collectiondetail?sid=1529367) local plugins={ { "rhysd/accelerated-jk", config = function() vim.keymap.set("n", "j", "(accelerated_jk_gj)") vim.keymap.set("n", "k", "(accelerated_jk_gk)") end, }, -- { -- "folke/persistence.nvim", -- config = function() -- -- restore the session for the current directory -- vim.api.nvim_set_keymap("n", "qs", [[lua require("persistence").load()]], {}) -- -- restore the last session -- vim.api.nvim_set_keymap("n", "ql", [[lua require("persistence").load({ last = true })]], {}) -- -- stop Persistence => session won't be saved on exit -- vim.api.nvim_set_keymap("n", "qd", [[lua require("persistence").stop()]], {}) -- end, -- }, "windwp/nvim-autopairs", -- 自动补全括号 -- 自动回到文件上次打开的行位置,默认是文件第一行 -- { -- "ethanholz/nvim-lastplace", -- config = true -- }, { "folke/flash.nvim", keys = { { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, }, { "folke/which-key.nvim", config = true }, -- { -- "folke/tokyonight.nvim", -- 主题 -- lazy = false, -- make sure we load this during startup if it is your main colorscheme -- priority = 1000, -- make sure to load this before all the other start plugins -- config = function() -- -- load the colorscheme here -- vim.cmd([[colorscheme tokyonight-moon]]) -- end, -- }, -- { -- "nvim-lualine/lualine.nvim", -- 状态栏图标 -- config = function() -- require('lualine').setup({ -- options = { -- theme = 'tokyonight' -- } -- }) -- end, -- dependencies = {{ "kyazdani42/nvim-web-devicons" }} -- }, "nvim-tree/nvim-tree.lua", -- 文档树 { "p00f/nvim-ts-rainbow", -- 配合treesitter,不同括号颜色区分 dependencies = {{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"}} -- 语法高亮 }, -- LSP 语法提示 { "neovim/nvim-lspconfig", dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", -- 这个相当于mason.nvim和lspconfig的桥梁 "folke/neodev.nvim", -- 解决 lsp 无法正常识别 neovim 提供的 vim api } }, -- 自动补全 "hrsh7th/nvim-cmp", "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", -- snippets引擎,不装这个自动补全会出问题 "saadparwaiz1/cmp_luasnip", "rafamadriz/friendly-snippets", "hrsh7th/cmp-path", -- 文件路径 "numToStr/Comment.nvim", -- gcc和gc注释 "lewis6991/gitsigns.nvim", -- 左则git提示 "kshenoy/vim-signature", -- 书签管理 { "nvim-telescope/telescope-file-browser.nvim", -- 文件检索 dependencies = { { "nvim-telescope/telescope.nvim", tag = '0.1.5' }, "nvim-lua/plenary.nvim"-- telescope依赖 } }, { "iamcco/markdown-preview.nvim", tag = 'v0.0.10', cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, ft = { "markdown" }, build = function() vim.fn["mkdp#util#install"]() end, }, -- 更轻量的Markdown预览插件,使用方式:`:Glow` -- "ellisonleao/glow.nvim", { "dhruvasagar/vim-table-mode", tag = 'v4.8.1' }, -- 用于快速编写markdown表格 } https://github.com/phpactor/phpactor/archive/refs/tags/2022.11.12.tar.gz