
本文所用配置以LunarVim的Nightly版本为基础。 Neovim版本: 0.9.0 插件管理器:lazy.nvim
你可以在LunarVim中,使用打开,将以下插件配置复制或替换到合适的位置中,然后重启lvim自动安装插件。
本文的配置将合理使用lazy.nvim的懒加载功能,只在需要的时候加载需要的插件,加快neovim的运行和加载速度,减少资源占用。
适合阅读本文的人群:有一定的neovim配置经验
你可以在 https://github.com/ADkun/my-lvim-config/blob/main/config.lua 这个网址看到我最新的config.lua完整配置文件。
由于B站的编辑器格式化功能很差,本文原文采用markdown格式编写,请移步下面链接查看,获得更好的体验。
请访问 https://github.com/ADkun/lvim-config-suggest/blob/main/README.md 以更好的格式化方式查看本文,有任何错误也会在这个文档里更新
这些配置是为了在config.lua中提前声明一些变量,避免冗长的写法,你可以将这些配置提前写在config.lua的前部。
local keymap = lvim.builtin.which_key.mappings
local vkeymap = lvim.builtin.which_key.vmappings
推荐度:★★
主页:https://github.com/nathom/filetype.nvim
简介:
filetype.nvim对neovim的filetype进行了优化,可以使打开文件时识别文件类型的速度更快。
在某些情况下,还可以修复由文件类型识别不正确导致的高亮不全问题。(如打开.h文件发现没有代码高亮)
使用方式:在config.lua中配置好,然后打开文件。
配置:
{
"nathom/filetype.nvim",
lazy = true,
event = "User FileOpened",
config = function()
require("filetype").setup({
overrides = {
extensions = {
h = "cpp",
},
}
})
end
}
上面配置中的表示将后缀的文件识别为文件类型,使文件被neovim识别为cpp文件,使用cpp文件的高亮。 除了以外,你还可以配置
literal:匹配全文件名
complex:使用正则表达式匹配路径和文件名
function_extensions:对指定类型的文件设置回调函数
function_literal:对指定全文件名的文件设置回调函数
function_complex:对指定正则表达式匹配的文件设置回调函数
shebang:对于包含了指定shebang的文件视为指定的文件类型,如#! /usr/bin/dash视为sh文件类型,以匹配不同类型的shell脚本文件。 具体配置方法见插件Github主页,里面有给出example。
推荐度:★★★
主页:https://github.com/folke/trouble.nvim
简介:
trouble.nvim实现了trouble这种预览窗口类型(类似于quickfix, loclist),这种窗口的特点是切换项目时会将打开前的窗口实时预览到对应的位置上,退出trouble窗口时会回到原来的位置。
trouble.nvim可以让你快速查看你的工作区、文件中的LSP警告列表。
使用方式:热键打开窗口
配置:
{
"folke/trouble.nvim",
lazy = true,
cmd = { "TroubleToggle", "Trouble", "TroubleRefresh" },
config = function()
require("trouble").setup()
end,
},
键位配置(which-key):
keymap["t"] = { name = "Diagnostics" }
keymap["tt"] = { "<cmd>TroubleToggle<cr>", "trouble" }
keymap["tw"] = { "<cmd>TroubleToggle workspace_diagnostics<cr>", "workspace" }
keymap["td"] = { "<cmd>TroubleToggle document_diagnostics<cr>", "document" }
keymap["tq"] = { "<cmd>TroubleToggle quickfix<cr>", "quickfix" }
keymap["tl"] = { "<cmd>TroubleToggle loclist<cr>", "loclist" }
keymap["tr"] = { "<cmd>TroubleToggle lsp_references<cr>", "references" }
插件只会在你使用快捷键的时候才加载。 注:which-key的配置方式需要你以<leader>键开头,比如上面配置的keymap["tt"],你需要按<leader>tt。 LunarVim的默认键是
推荐度:★★★★★
主页:https://github.com/ggandor/leap.nvim
简介:
leap.nvim可以让你的光标快速在可视范围内跳转。
你只需要按下引导键(自定义的第一个键),然后输入你想跳转到的地方的相邻2个字符,如有重复,输入最后一个提示字符即可。
可以配合其它neovim快捷键一起使用,如"c", "d", "y"
使用方式:见下面的快捷键介绍,也可以配合"c", "d", "y"等neovim原本的功能键一起使用。
配置:
{
&quot;ggandor/leap.nvim&quot;,
lazy = true,
keys = { &quot;r&quot;, &quot;R&quot;, &quot;W&quot;, &quot;dr&quot;, &quot;dR&quot;, &quot;yr&quot;, &quot;yR&quot;, &quot;cr&quot;, &quot;cR&quot; },
config = function()
require(&quot;leap&quot;).opts.highlight_unlabeled_phase_one_targets = true
-- leap.add_default_mappings()
vim.keymap.set({ &quot;x&quot;, &quot;o&quot;, &quot;n&quot; }, &quot;r&quot;, &quot;&lt;Plug&gt;(leap-forward-to)&quot;)
vim.keymap.set({ &quot;x&quot;, &quot;o&quot;, &quot;n&quot; }, &quot;R&quot;, &quot;&lt;Plug&gt;(leap-backward-to)&quot;)
vim.keymap.set({ &quot;x&quot;, &quot;o&quot;, &quot;n&quot; }, &quot;W&quot;, &quot;&lt;Plug&gt;(leap-from-window)&quot;)
end,
},
快捷键介绍:
r:在当前光标往右往下查找。
R:在当前光标往左往上查找。
W:多窗口情况下,可快速跳转到其它窗口的内容。
推荐度:★★★★★
主页:https://github.com/ggandor/flit.nvim
简介:
flit.nvim是leap.nvim同一个作者产出的,flit.nvim需要依赖于leap.nvim。
flit.nvim可以增强neovim的"f", "F", "t", "T"这几个键的功能,同样是一个光标跳转插件。
使用方式:按"f", "F", "t", "T",然后键入你想去的目标字符。如果本次没有到达你想去的目标,再次按下"f"或"t",光标会跳到下一个目标。
配置:
{
&quot;ggandor/flit.nvim&quot;,
lazy = true,
keys = { &quot;f&quot;, &quot;F&quot;, &quot;t&quot;, &quot;T&quot; },
dependencies = { &quot;ggandor/leap.nvim&quot; },
config = function()
require(&quot;flit&quot;).setup({
keys = { f = &quot;f&quot;, F = &quot;F&quot;, t = &quot;t&quot;, T = &quot;T&quot;, },
labeled_modes = &quot;v&quot;,
multiline = true,
opts = {},
})
end,
},
推荐度:★★★★
主页:https://github.com/phaazon/hop.nvim
简介:
hop.nvim与leap.nvim一样,同样是一款可视范围内光标跳转的插件。
与leap.nvim不同,这款插件有更多功能,并且支持单字符的跳转。
使用方式:以本配置为例,按"E",然后键入可视范围内你想去的那个字符,最后输入1-2个提示字符就可以跳到目标位置了。 注:配置中以注释的方式将其它一些函数屏蔽掉了,仅保留单字符跳转功能,作为leap.nvim的补充。如有需要可去掉注释符自行配置。
配置:
{
&quot;phaazon/hop.nvim&quot;,
lazy = true,
keys = { &quot;E&quot; },
config = function()
require(&quot;hop&quot;).setup({})
-- vim.api.nvim_set_keymap(&quot;n&quot;, &quot;R&quot;, &quot;&lt;cmd&gt;HopChar2&lt;cr&gt;&quot;, { silent = true })
vim.api.nvim_set_keymap(&quot;n&quot;, &quot;E&quot;, &quot;&lt;cmd&gt;HopChar1&lt;cr&gt;&quot;, { silent = true })
-- vim.api.nvim_set_keymap(&quot;n&quot;, &quot;U&quot;, &quot;&lt;cmd&gt;HopWord&lt;cr&gt;&quot;, { silent = true })
-- vim.api.nvim_set_keymap(&quot;n&quot;, &quot;C&quot;, &quot;&lt;cmd&gt;HopLine&lt;cr&gt;&quot;, { silent = true })
-- vim.api.nvim_set_keymap(&quot;n&quot;, &quot;P&quot;, &quot;&lt;cmd&gt;HopPattern&lt;cr&gt;&quot;, { silent = true })
end,
},
推荐度:★★★★
主页:https://github.com/HiPhish/nvim-ts-rainbow2 简介:
nvim-ts-rainbow2基于nvim-treesitter,将配对的括号进行彩色的标注,方便辨认。 使用方式:配置即用
配置:
{
&quot;HiPhish/nvim-ts-rainbow2&quot;,
-- Bracket pair rainbow colorize
lazy = true,
event = { &quot;User FileOpened&quot; },
},
然后在config.lua另外一个地方加上这一行(非插件的config函数里)
lvim.builtin.treesitter.rainbow.enable = true
推荐度:★★★
主页:https://github.com/nvim-treesitter/nvim-treesitter-context
简介:
nvim-treesitter-context是一款基于nvim-treesitter的上文文固定插件。
它可以将当前函数的函数头固定在neovim界面的前几行,让你知道当前在编辑的是什么类、函数或方法。 使用方式:配置即用
配置:
{
&quot;romgrk/nvim-treesitter-context&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;treesitter-context&quot;).setup({
enable = true,
throttle = true,
max_lines = 0,
patterns = {
default = {
&quot;class&quot;,
&quot;function&quot;,
&quot;method&quot;,
},
},
})
end,
},
推荐度:★★★
主页:https://github.com/ThePrimeagen/harpoon
简介:当前项目的文件收藏夹
使用方式:快捷键使用
<leader>ohh:在Telescope中打开Harpoon收藏的文件
<leader>oht:打开Harpoon本身自带的收藏夹
<leader>ohf:将当前文件加入到收藏夹
<leader>ohd:将当前文件从收藏夹中删除
<leader>ohn:切换到下一个收藏夹文件
<leader>ohp:切换到上一个收藏夹文件
配置:
{
&quot;ThePrimeagen/harpoon&quot;,
lazy = true,
cmd = &quot;Telescope harpoon marks&quot;,
dependencies = {
&quot;nvim-lua/plenary.nvim&quot;,
},
config = function()
require(&quot;harpoon&quot;).setup({})
require(&quot;telescope&quot;).load_extension(&quot;harpoon&quot;)
end,
}
快捷键配置:
keymap[&quot;oh&quot;] = { name = &quot;+Harpoon&quot; }
keymap[&quot;ohf&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;harpoon.mark&#39;).add_file()&lt;cr&gt;&quot;, &quot;Add File&quot; }
keymap[&quot;oht&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;harpoon.ui&#39;).toggle_quick_menu()&lt;cr&gt;&quot;, &quot;Toggle Menu&quot; }
keymap[&quot;ohn&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;harpoon.ui&#39;).nav_next()&lt;cr&gt;&quot;, &quot;Next&quot; }
keymap[&quot;ohp&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;harpoon.ui&#39;).nav_prev()&lt;cr&gt;&quot;, &quot;Prev&quot; }
keymap[&quot;ohh&quot;] = { &quot;&lt;cmd&gt;Telescope harpoon marks&lt;cr&gt;&quot;, &quot;Telescope Harpoon&quot; }
keymap[&quot;ohd&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;harpoon.mark&#39;).rm_file()&lt;cr&gt;&quot;, &quot;Remove File&quot; }
推荐度:★★★★
主页:https://github.com/JoosepAlviste/nvim-ts-context-commentstring
简介:
本插件基于nvim-treesitter,根据当前光标在文中的位置,配合Comment.nvim,自动选择合适的注释格式。
使用方式:配置即用。
配置:
{
&quot;JoosepAlviste/nvim-ts-context-commentstring&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
},
推荐度:★★★★
主页:https://github.com/rmagatti/goto-preview
简介:本插件可以以浮动窗口的形式预览符号的定义、实现等信息。
使用方式:光标定位到目标符号,快捷键使用
gpd:预览符号定义
gpi:预览符号实现
gpr:预览符号引用
gpt:预览类型定义
配置:
{
&quot;rmagatti/goto-preview&quot;,
lazy = true,
keys = { &quot;gp&quot; },
config = function()
require(&quot;goto-preview&quot;).setup({
width = 120,
height = 25,
default_mappings = true,
debug = false,
opacity = nil,
post_open_hook = nil,
-- You can use &quot;default_mappings = true&quot; setup option
-- Or explicitly set keybindings
-- vim.cmd(&quot;nnoremap gpd &lt;cmd&gt;lua require(&#39;goto-preview&#39;).goto_preview_definition()&lt;CR&gt;&quot;)
-- vim.cmd(&quot;nnoremap gpi &lt;cmd&gt;lua require(&#39;goto-preview&#39;).goto_preview_implementation()&lt;CR&gt;&quot;)
-- vim.cmd(&quot;nnoremap gP &lt;cmd&gt;lua require(&#39;goto-preview&#39;).close_all_win()&lt;CR&gt;&quot;)
})
end,
},
推荐度:★★★★★
主页:https://github.com/ethanholz/nvim-lastplace
简介:自动记忆当前文件位置,在下次打开时定位到上次位置。
使用方式:配置即用
配置:
{
&quot;ethanholz/nvim-lastplace&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;nvim-lastplace&quot;).setup({
lastplace_ignore_buftype = { &quot;quickfix&quot;, &quot;nofile&quot;, &quot;help&quot; },
lastplace_ignore_filetype = {
&quot;gitcommit&quot;,
&quot;gitrebase&quot;,
&quot;svn&quot;,
&quot;hgcommit&quot;,
},
lastplace_open_folds = true,
})
end,
}
推荐度:★★★
主页:https://github.com/folke/todo-comments.nvim
简介:高亮注释中的关键词,按需安装。
使用方式:在注释中以以下关键词,并加上英文冒号,然后输入注释内容。
HACK
NOTE
TODO
WARN
WARNING
BUG
FIX
PREF
配置:
{
&quot;folke/todo-comments.nvim&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;todo-comments&quot;).setup()
end,
}
推荐度:★★★★★
主页:https://github.com/kylechui/nvim-surround
简介:使用快捷键配合textobjects快速地添加/修改/删除各种包括符,如()、[]、{}、<>等。
使用方式:快捷键使用,下面举几个例子:
ysiw":将当前光标选中的单词用双引号包围,其中,ys是本插件的触发快捷键,iw是inner word的意思,这是neovim自带的一种textobject选中方式。
ds):将当前光标位置相邻的最内层的小括号删除。
cs)}:将当前光标位置相邻的最内层的小括号替换为大括号。
配置:
{
&quot;kylechui/nvim-surround&quot;,
lazy = true,
keys = { &quot;cs&quot;, &quot;ds&quot;, &quot;ys&quot; },
config = function()
require(&quot;nvim-surround&quot;).setup({})
end,
},
推荐度:★★★★
主页:https://github.com/nvim-pack/nvim-spectre
简介:搜索并替换项目中所有文件/当前文件/当前选中区域的内容
使用方式:快捷键使用
在文件窗口中
<leader>osf:在当前文件搜索
<leader>oss:在当前目录(项目)中搜索,包括子文件夹
<leader>osv:在当前选中区域搜索
<leader>osw:在当前选中区域搜索单词
在Spectre窗口中
<leader>R:替换所有
<leader>rc:替换当前光标所在行的匹配项
<cr>:跳到该匹配项的原文件位置
<leader>q:将所有匹配项发送到quickfix中
?:查看所有按键
注:在Spectre窗口中是无法使用来退出窗口的,因为有快捷键冲突。需要用来退出。
配置:
{
&quot;windwp/nvim-spectre&quot;,
lazy = true,
cmd = { &quot;Spectre&quot; },
config = function()
require(&quot;spectre&quot;).setup()
end,
},
快捷键配置:
keymap[&quot;os&quot;] = { name = &quot;+Spectre&quot; }
keymap[&quot;oss&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;spectre&#39;).open()&lt;cr&gt;&quot;, &quot;Spectre Open&quot; }
vkeymap[&quot;osw&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;spectre&#39;).open_visual({select_word=true})&lt;cr&gt;&quot;, &quot;Spectre in Visual Word&quot; }
vkeymap[&quot;osv&quot;] = { &quot;&lt;esc&gt;&lt;cmd&gt;lua require(&#39;spectre&#39;).open_visual()&lt;CR&gt;&quot;, &quot;Spectre in Visual&quot; }
keymap[&quot;osf&quot;] = { &quot;viw&lt;cmd&gt;lua require(&#39;spectre&#39;).open_file_search()&lt;CR&gt;&quot;, &quot;Spectre in File&quot; }
推荐度:★★★★
主页:https://github.com/kevinhwang91/nvim-bqf
简介:增强你的quickfix窗口
使用方式:配置即可显示增强的quickfix窗口,然后在quickfix窗口内使用对应快捷键操作quickfix
z,:将预览窗口的切换为全屏/半屏
o:将当前quickfix条目以drop的方式(如果缓冲区没有就打开新缓冲区,如果有就切换到那个缓冲)
更多快捷键请查看配置以及参考Github主页
配置(并不完美,有兴趣的可以自行修改):
{
&quot;kevinhwang91/nvim-bqf&quot;,
-- quickfix preview and other functions
lazy = true,
event = { &quot;WinNew&quot; },
config = function()
require(&quot;bqf&quot;).setup({
auto_enable = true,
auto_resize_height = true,
preview = {
win_height = 12,
win_vheight = 12,
delay_syntax = 80,
border_chars = { &quot;┃&quot;, &quot;┃&quot;, &quot;━&quot;, &quot;━&quot;, &quot;┏&quot;, &quot;┓&quot;, &quot;┗&quot;, &quot;┛&quot;, &quot;█&quot; },
should_preview_cb = function(bufnr, qwinid)
local ret = true
local bufname = vim.api.nvim_buf_get_name(bufnr)
local fsize = vim.fn.getfsize(bufname)
if fsize &gt; 100 * 1024 then
-- skip file size greater than 100k
ret = false
elseif bufname:match(&quot;^fugitive://&quot;) then
-- skip fugitive buffer
ret = false
end
return ret
end,
},
func_map = {
drop = &quot;o&quot;,
openc = &quot;O&quot;,
split = &quot;&lt;C-s&gt;&quot;,
tabdrop = &quot;&lt;C-t&gt;&quot;,
tabc = &quot;&quot;,
vsplit = &quot;&lt;C-v&gt;&quot;,
ptogglemode = &quot;z,&quot;,
stoggleup = &quot;&quot;,
},
filter = {
fzf = {
action_for = { [&quot;ctrl-s&quot;] = &quot;split&quot;, [&quot;ctrl-t&quot;] = &quot;tab drop&quot; },
extra_opts = { &quot;--bind&quot;, &quot;ctrl-o:toggle-all&quot;, &quot;--prompt&quot;, &quot;&gt; &quot; },
},
},
})
end,
}
推荐度:★★★
主页:https://github.com/andymass/vim-matchup
简介:在你光标位置将if..else if..else等语言内的对应标签高亮。扩展你的键能力。
使用方式:配置即用,在if等可以配对的标签处点击跳到下一个匹配处
配置:
{
&quot;andymass/vim-matchup&quot;,
-- Highlight, jump between pairs like if..else
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
vim.g.matchup_matchparen_offscreen = { method = &quot;popup&quot; }
lvim.builtin.treesitter.matchup.enable = true
end,
},
推荐度:★★★★★
主页:https://github.com/folke/persistence.nvim
简介:自动保存你的session到文件中,在下次打开相同目录/项目时,你可以手动加载session恢复之前的工作状态。
使用方式:退出即自动保存,打开后使用来加载session
配置:
{
&quot;folke/persistence.nvim&quot;,
-- Restore last session of current dir
lazy = true,
event = &quot;BufReadPre&quot;, -- this will only start session saving when an actual file was opened
config = function()
require(&quot;persistence&quot;).setup({
dir = vim.fn.expand(vim.fn.stdpath(&quot;config&quot;) .. &quot;/session/&quot;),
options = { &quot;buffers&quot;, &quot;curdir&quot;, &quot;tabpages&quot;, &quot;winsize&quot; },
pre_save = nil,
})
end,
} 快捷键配置:
keymap[&quot;a&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;persistence&#39;).load()&lt;cr&gt;&quot;, &quot;Restore last session for current dir&quot; }
keymap[&quot;S&quot;] = { name = &quot;+Session&quot; }
keymap[&quot;Sc&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;persistence&#39;).load()&lt;cr&gt;&quot;, &quot;Restore last session for current dir&quot; }
keymap[&quot;Sl&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;persistence&#39;).load({ last = true })&lt;cr&gt;&quot;, &quot;Restore last session&quot; }
keymap[&quot;SQ&quot;] = { &quot;&lt;cmd&gt;lua require(&#39;persistence&#39;).stop()&lt;cr&gt;&quot;, &quot;Quit without saving session&quot; }
推荐度:★★★★★
主页:https://github.com/max397574/better-escape.nvim
简介:可以自定义任意2个按键来退出Insert模式。
使用方式:在Insert模式下,在200ms(可修改)内连续按下"jk"或"jl"(可修改)退出Insert模式。
注:如果电脑比较卡,200ms可能不够,可以修改为更长一些的时间。
配置:
{
&quot;max397574/better-escape.nvim&quot;,
lazy = true,
event = { &quot;InsertEnter&quot; },
config = function()
require(&quot;better_escape&quot;).setup({
mapping = { &quot;jk&quot;, &quot;jl&quot; },
timeout = 200,
clear_empty_lines = false,
keys = &quot;&lt;Esc&gt;&quot;,
})
end,
}
推荐度:★★★
主页:https://github.com/abecodes/tabout.nvim
简介:可以在Insert模式下,按跳出括号。
使用方式:在Insert模式下,如果你的光标在括号或引号里面(可配置),按键跳出括号 注:实际使用时,因为优先级比nvim-cmp低,所以在弹出补全窗口时,需要按关闭补全窗口才能使用,所以体验并不是特别好。
配置:
{
&quot;abecodes/tabout.nvim&quot;,
lazy = true,
event = { &quot;InsertEnter&quot; },
config = function()
require(&quot;tabout&quot;).setup({
tabkey = &quot;&lt;Tab&gt;&quot;,
backwards_tabkey = &quot;&lt;S-Tab&gt;&quot;,
act_as_tab = true,
act_as_shift_tab = false,
default_tab = &quot;&lt;C-t&gt;&quot;,
default_shift_tab = &quot;&lt;C-d&gt;&quot;,
enable_backwards = true,
completion = true,
tabouts = {
{ open = &quot;&#39;&quot;, close = &quot;&#39;&quot; },
{ open = &#39;&quot;&#39;, close = &#39;&quot;&#39; },
{ open = &quot;`&quot;, close = &quot;`&quot; },
{ open = &quot;(&quot;, close = &quot;)&quot; },
{ open = &quot;[&quot;, close = &quot;]&quot; },
{ open = &quot;{&quot;, close = &quot;}&quot; },
},
ignore_beginning = true,
exclude = {
&quot;qf&quot;,
&quot;NvimTree&quot;,
&quot;toggleterm&quot;,
&quot;TelescopePrompt&quot;,
&quot;alpha&quot;,
&quot;netrw&quot;,
},
})
end,
after = { &quot;nvim-cmp&quot; },
},
推荐度:★★
主页:https://github.com/ibhagwan/smartyank.nvim
简介:在"dd"等不希望将内容复制到系统剪贴板的时候不复制到系统剪贴板。支持在SSH等情况复制到系统剪贴板。
使用方式:配置即用。 注:可能是因为个人环境问题,没有实际体验到它的功能,但对性能没啥影响,还是装上吧。
配置:
{
&quot;ibhagwan/smartyank.nvim&quot;,
lazy = true,
event = &quot;User FileOpened&quot;,
config = function()
require(&quot;smartyank&quot;).setup()
end,
},
推荐度:★★★★★
主页:https://github.com/chentoast/marks.nvim
简介:在左侧栏中显示这一行标记的marks,可以显示当前文件/所有缓冲区的所有marks/所有缓冲区的大写marks
使用方式:
mx:neovim原本的mark方式进行标记,x为标记名。
m;:自动对当前行按字母顺序进行小写标记
dmx:x为标记名,删除某个标记名
mX:X为大写标记名,大写的标记可以跨文件跳转。
<leader>oma:显示所有标记(包括小写大写,在所有缓冲区中)
<leader>omb:显示当前buffer中的所有标记(包括小写大写)
<leader>omg:显示所有大写标记
配置:
{
&quot;chentoast/marks.nvim&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;marks&quot;).setup({
default_mappings = true,
-- builtin_marks = { &quot;.&quot;, &quot;&lt;&quot;, &quot;&gt;&quot;, &quot;^&quot; },
cyclic = true,
force_write_shada = false,
refresh_interval = 250,
sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 },
excluded_filetypes = {
&quot;qf&quot;,
&quot;NvimTree&quot;,
&quot;toggleterm&quot;,
&quot;TelescopePrompt&quot;,
&quot;alpha&quot;,
&quot;netrw&quot;,
},
bookmark_0 = {
sign = &quot;&quot;,
virt_text = &quot;hello world&quot;,
annotate = false,
},
mappings = {},
})
end,
} 快捷键配置:
keymap[&quot;om&quot;] = { name = &quot;+Marks&quot; }
keymap[&quot;oma&quot;] = { &quot;&lt;cmd&gt;MarksListAll&lt;CR&gt;&quot;, &quot;Show All Marks&quot; }
keymap[&quot;omb&quot;] = { &quot;&lt;cmd&gt;MarksListBuf&lt;CR&gt;&quot;, &quot;Show Marks in Buffer&quot; }
keymap[&quot;omg&quot;] = { &quot;&lt;cmd&gt;MarksListGlobal&lt;CR&gt;&quot;, &quot;Show Marks Global&quot; }
推荐度:★★★★★
主页:https://github.com/zbirenbaum/neodim
简介:将没有使用到的变量进行暗淡处理。
使用方式:配置即用
配置:
{
&quot;zbirenbaum/neodim&quot;,
lazy = true,
event = &quot;LspAttach&quot;,
config = function()
require(&quot;neodim&quot;).setup({
alpha = 0.75,
blend_color = &quot;#000000&quot;,
update_in_insert = {
enable = true,
delay = 100,
},
hide = {
virtual_text = true,
signs = false,
underline = false,
},
})
end,
}
推荐度:★★★★★
主页:https://github.com/anuvyklack/windows.nvim
简介:通过几个函数可以将当前neovim窗口进行全屏/垂直全屏/水平全屏/等分
使用方式:快捷键使用
配置:
{
&quot;anuvyklack/windows.nvim&quot;,
lazy = true,
cmd = { &quot;WindowsMaximize&quot;, &quot;WindowsMaximizeVertically&quot;, &quot;WindowsMaximizeHorizontally&quot;, &quot;WindowsEqualize&quot; },
dependencies = {
&quot;anuvyklack/middleclass&quot;,
},
config = function()
require(&quot;windows&quot;).setup({
autowidth = {
enable = false,
},
ignore = {
buftype = { &quot;quickfix&quot; },
filetype = {
&quot;NvimTree&quot;,
&quot;neo-tree&quot;,
&quot;undotree&quot;,
&quot;gundo&quot;,
&quot;qf&quot;,
&quot;toggleterm&quot;,
&quot;TelescopePrompt&quot;,
&quot;alpha&quot;,
&quot;netrw&quot;,
},
},
})
end,
} 快捷键配置:
keymap[&quot;m&quot;] = { &quot;&lt;cmd&gt;WindowsMaximize&lt;cr&gt;&quot;, &quot;Window Maximize&quot; }
keymap[&quot;z&quot;] = { name = &quot;+Windows&quot; }
keymap[&quot;zm&quot;] = { &quot;&lt;cmd&gt;WindowsMaximize&lt;cr&gt;&quot;, &quot;Window Maximize&quot; }
keymap[&quot;zv&quot;] = { &quot;&lt;cmd&gt;WindowsMaximizeVertically&lt;cr&gt;&quot;, &quot;Window Vertically Maximize&quot; }
keymap[&quot;zh&quot;] = { &quot;&lt;cmd&gt;WindowsMaximizeHorizontally&lt;cr&gt;&quot;, &quot;Window Horizontally Maximize&quot; }
keymap[&quot;ze&quot;] = { &quot;&lt;cmd&gt;WindowsEqualize&lt;cr&gt;&quot;, &quot;Window Equalize&quot; }
推荐度:★★★★★
主页:https://github.com/rcarriga/nvim-notify
简介:将各种提示显示为弹窗
使用方式:配置即用
<leader>onm:显示messages(非noice功能)
注:只使用nvim-notify的话,只能将vim.notify重定向输出到notify窗口中,需要将所有消息重定向到notify的话,需要装noice.nvim 注2:为了性能,配置中将动画效果取消了,需要的可以自行开启(修改项)
配置:
{
&quot;rcarriga/nvim-notify&quot;,
lazy = true,
event = &quot;VeryLazy&quot;,
config = function()
local notify = require(&quot;notify&quot;)
notify.setup({
-- &quot;fade&quot;, &quot;slide&quot;, &quot;fade_in_slide_out&quot;, &quot;static&quot;
stages = &quot;static&quot;,
on_open = nil,
on_close = nil,
timeout = 3000,
fps = 1,
render = &quot;default&quot;,
background_colour = &quot;Normal&quot;,
max_width = math.floor(vim.api.nvim_win_get_width(0) / 2),
max_height = math.floor(vim.api.nvim_win_get_height(0) / 4),
-- minimum_width = 50,
-- ERROR &gt; WARN &gt; INFO &gt; DEBUG &gt; TRACE
level = &quot;TRACE&quot;,
})
vim.notify = notify
end,
}
推荐度:★★★★★
主页:https://github.com/folke/noice.nvim
简介:一个覆写了很多neovim原本UI的插件,很大幅度地提升了美观性。
将messages重定向到notify
将搜索、命令显示为独立的命令框,并去除最底部的显示栏,节省空间。
显示过往Notifications
Telescope整合
使用方式:配置即用,快捷键呼出历史窗口等功能。
<leader>onn:显示Notifications历史
<leader>ont:在Telescope中显示Notifications历史
<leader>ond:临时禁用Noice
<leader>one:启用Noice
配置:
{
&quot;folke/noice.nvim&quot;,
enabled = enable_noice,
lazy = true,
event = &quot;user fileopened&quot;,
dependencies = { &quot;rcarriga/nvim-notify&quot;, &quot;muniftanjim/nui.nvim&quot; },
config = function()
require(&quot;noice&quot;).setup({
lsp = {
progress = {
enabled = false,
},
},
presets = {
bottom_search = false,
command_palette = true,
long_message_to_split = true,
inc_rename = false,
lsp_doc_border = true,
},
messages = {
enabled = true,
view = &quot;notify&quot;,
view_error = &quot;notify&quot;,
view_warn = &quot;notify&quot;,
view_history = &quot;messages&quot;,
view_search = &quot;virtualtext&quot;,
},
health = {
checker = false,
},
})
end,
} 快捷键配置:
keymap[&quot;on&quot;] = { name = &quot;+Notify&quot; }
keymap[&quot;onn&quot;] = { &quot;&lt;cmd&gt;Notifications&lt;cr&gt;&quot;, &quot;Show Notifications&quot; }
keymap[&quot;ont&quot;] = { &quot;&lt;cmd&gt;Noice telescope&lt;cr&gt;&quot;, &quot;Show Notifications in Telescope&quot; }
keymap[&quot;onm&quot;] = { &quot;&lt;cmd&gt;messages&lt;cr&gt;&quot;, &quot;Show Messages&quot; }
keymap[&quot;ond&quot;] = { &quot;&lt;cmd&gt;NoiceDisable&lt;cr&gt;&quot;, &quot;Noice Disable&quot; }
keymap[&quot;one&quot;] = { &quot;&lt;cmd&gt;NoiceEnable&lt;cr&gt;&quot;, &quot;Noice Enable&quot; }
推荐度:★★★
主页:https://github.com/kevinhwang91/nvim-ufo
简介:启用neovim的折叠功能,在左侧栏显示可折叠的项目,并能够自定义折叠显示的内容
使用方式:快捷键使用
zm:折叠整个文件的所有内容
zM:同上
zr:展开整个文件的所有内容
zR:同上
zo或l:展开当前光标所在行的1层折叠
zO:展开当前光标所在行的所有折叠
zc:当前光标所在行进行折叠
<leader>oud:禁用Ufo
<leader>oue:启用Ufo
注:配置中使用了,意味着并不会在文件加载时加载本插件,你需要手动输入一次或以加载本插件。 注2:在多窗口的状态下,可能会有一些BUG,如保存时自动把另外窗口全部折叠了,这时候可以临时关闭UFO()。
{
&quot;kevinhwang91/nvim-ufo&quot;,
lazy = true,
cmd = { &quot;UfoDisable&quot;, &quot;UfoEnable&quot; },
dependencies = {
&quot;kevinhwang91/promise-async&quot;,
},
config = function()
vim.o.foldcolumn = &quot;1&quot; -- &#39;0&#39; is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.cmd([[highlight AdCustomFold guifg=#bf8040]])
local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (&quot; %d &quot;):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth &gt; curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, { chunkText, hlGroup })
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth &lt; targetWidth then
suffix = suffix .. (&quot; &quot;):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
-- Second line
local lines = vim.api.nvim_buf_get_lines(0, lnum, lnum + 1, false)
local secondLine = nil
if #lines == 1 then
secondLine = lines[1]
elseif #lines &gt; 1 then
secondLine = lines[2]
end
if secondLine ~= nil then
table.insert(newVirtText, { secondLine, &quot;AdCustomFold&quot; })
end
table.insert(newVirtText, { suffix, &quot;MoreMsg&quot; })
return newVirtText
end
require(&quot;ufo&quot;).setup({
provider_selector = function(bufnr, filetype, buftype)
return { &quot;treesitter&quot;, &quot;indent&quot; }
end,
fold_virt_text_handler = handler,
})
end,
} 推荐度:★★★★
主页:https://github.com/s1n7ax/nvim-window-picker
简介:在打开的多个窗口快速跳转、交换。
使用方式:
键入,w,然后键入1个小写字母键选择窗口,跳转到对应窗口。
键入,W,然后键入1个小写字母键选择窗口,将当前焦点窗口与对应窗口交换。
配置:
{
&quot;s1n7ax/nvim-window-picker&quot;,
lazy = true,
event = { &quot;WinNew&quot; },
config = function()
local picker = require(&quot;window-picker&quot;)
picker.setup({
autoselect_one = true,
include_current = false,
filter_rules = {
bo = {
filetype = { &quot;neo-tree&quot;, &quot;neo-tree-popup&quot;, &quot;notify&quot;, &quot;quickfix&quot; },
buftype = { &quot;terminal&quot; },
},
},
other_win_hl_color = &quot;#e35e4f&quot;,
})
vim.keymap.set(&quot;n&quot;, &quot;,w&quot;, function()
local picked_window_id = picker.pick_window({
include_current_win = true,
}) or vim.api.nvim_get_current_win()
vim.api.nvim_set_current_win(picked_window_id)
end, { desc = &quot;Pick a window&quot; })
-- Swap two windows using the awesome window picker
local function swap_windows()
local window = picker.pick_window({
include_current_win = false,
})
local target_buffer = vim.fn.winbufnr(window)
-- Set the target window to contain current buffer
vim.api.nvim_win_set_buf(window, 0)
-- Set current window to contain target buffer
vim.api.nvim_win_set_buf(0, target_buffer)
end
vim.keymap.set(&quot;n&quot;, &quot;,W&quot;, swap_windows, { desc = &quot;Swap windows&quot; })
end,
} 推荐度:★★★★★
主页:https://github.com/simrat39/symbols-outline.nvim
简介:以右侧栏形式显示当前文件的大纲、标题、符号
使用方式:快捷键打开侧栏
<leader>oo:打开symbols-outline侧边栏 在侧栏的快捷键:
<cr>:回车定位到符号位置,并焦点到目标窗口。
o:定位到符号位置,但焦点保留在symbols-outline窗口。
<C-space>:显示对应符号的hover窗口
K:打开当前符号的预览窗口。
r:重命名当前符号
a:代码action
h:当前光标处折叠
l:当前光标处展开
P:折叠所有
U:展开所有折叠
Q:重置折叠
注:需要LSP支持
配置:
{
&quot;simrat39/symbols-outline.nvim&quot;,
lazy = true,
cmd = { &quot;SymbolsOutline&quot;, &quot;SymbolsOutlineOpen&quot;, &quot;SymbolsOutlineClose&quot; },
config = function()
local opts = {
highlight_hovered_item = true,
show_guides = true,
auto_preview = false,
position = &quot;right&quot;,
relative_width = true,
width = 25,
auto_close = false,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = &quot;Pmenu&quot;,
autofold_depth = nil,
auto_unfold_hover = true,
fold_markers = { &quot;&quot;, &quot;&quot; },
wrap = false,
keymaps = { -- These keymaps can be a string or a table for multiple keys
close = { &quot;&lt;Esc&gt;&quot;, &quot;q&quot; },
goto_location = &quot;&lt;Cr&gt;&quot;,
focus_location = &quot;o&quot;,
hover_symbol = &quot;&lt;C-space&gt;&quot;,
toggle_preview = &quot;K&quot;,
rename_symbol = &quot;r&quot;,
code_actions = &quot;a&quot;,
fold = &quot;h&quot;,
unfold = &quot;l&quot;,
fold_all = &quot;P&quot;,
unfold_all = &quot;U&quot;,
fold_reset = &quot;Q&quot;,
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = { icon = &quot;&quot;, hl = &quot;@text.uri&quot; },
Module = { icon = &quot;&quot;, hl = &quot;@namespace&quot; },
Namespace = { icon = &quot;&quot;, hl = &quot;@namespace&quot; },
Package = { icon = &quot;&quot;, hl = &quot;@namespace&quot; },
Class = { icon = &quot;𝓒&quot;, hl = &quot;@type&quot; },
Method = { icon = &quot;ƒ&quot;, hl = &quot;@method&quot; },
Property = { icon = &quot;&quot;, hl = &quot;@method&quot; },
Field = { icon = &quot;&quot;, hl = &quot;@field&quot; },
Constructor = { icon = &quot;&quot;, hl = &quot;@constructor&quot; },
Enum = { icon = &quot;&quot;, hl = &quot;@type&quot; },
Interface = { icon = &quot;ﰮ&quot;, hl = &quot;@type&quot; },
Function = { icon = &quot;&quot;, hl = &quot;@function&quot; },
Variable = { icon = &quot;&quot;, hl = &quot;@constant&quot; },
Constant = { icon = &quot;&quot;, hl = &quot;@constant&quot; },
String = { icon = &quot;𝓐&quot;, hl = &quot;@string&quot; },
Number = { icon = &quot;#&quot;, hl = &quot;@number&quot; },
Boolean = { icon = &quot;&quot;, hl = &quot;@boolean&quot; },
Array = { icon = &quot;&quot;, hl = &quot;@constant&quot; },
Object = { icon = &quot;&quot;, hl = &quot;@type&quot; },
Key = { icon = &quot;🔐&quot;, hl = &quot;@type&quot; },
Null = { icon = &quot;NULL&quot;, hl = &quot;@type&quot; },
EnumMember = { icon = &quot;&quot;, hl = &quot;@field&quot; },
Struct = { icon = &quot;𝓢&quot;, hl = &quot;@type&quot; },
Event = { icon = &quot;🗲&quot;, hl = &quot;@type&quot; },
Operator = { icon = &quot;+&quot;, hl = &quot;@operator&quot; },
TypeParameter = { icon = &quot;𝙏&quot;, hl = &quot;@parameter&quot; },
Component = { icon = &quot;&quot;, hl = &quot;@function&quot; },
Fragment = { icon = &quot;&quot;, hl = &quot;@constant&quot; },
},
}
require(&quot;symbols-outline&quot;).setup(opts)
end,
},
推荐度:★★★★
主页:https://github.com/nvim-zh/colorful-winsep.nvim
简介:打开多窗口时,在当前焦点窗口周围显示紫色的边框
使用方式:配置即用
配置:
{
&quot;nvim-zh/colorful-winsep.nvim&quot;,
lazy = true,
event = &quot;WinNew&quot;,
config = function()
require(&quot;colorful-winsep&quot;).setup()
end,
}
推荐度:★★★★
主页:https://github.com/booperlv/nvim-gomove
简介:通过快捷键将当前选中区域/当前行进行移动,并遵循缩进
使用方式:
Normal模式:
<M-h/l>:向左/右移动当前光标处的字符
<M-j/k:将当前行向下/上移动,遵循缩进
Visual模式:
<M-j/k/h/l>:将当前选中区域向下/上/左/右移动,遵循缩进
配置:
{
&quot;booperlv/nvim-gomove&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;gomove&quot;).setup({
map_defaults = false,
reindent = true,
undojoin = true,
move_past_end_col = false,
})
local map = vim.api.nvim_set_keymap
map(&quot;n&quot;, &quot;&lt;M-h&gt;&quot;, &quot;&lt;Plug&gt;GoNSMLeft&quot;, { noremap = true, silent = true })
map(&quot;n&quot;, &quot;&lt;M-j&gt;&quot;, &quot;&lt;Plug&gt;GoNSMDown&quot;, { noremap = true, silent = true })
map(&quot;n&quot;, &quot;&lt;M-k&gt;&quot;, &quot;&lt;Plug&gt;GoNSMUp&quot;, { noremap = true, silent = true })
map(&quot;n&quot;, &quot;&lt;M-l&gt;&quot;, &quot;&lt;Plug&gt;GoNSMRight&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;M-h&gt;&quot;, &quot;&lt;Plug&gt;GoVSMLeft&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;M-j&gt;&quot;, &quot;&lt;Plug&gt;GoVSMDown&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;M-k&gt;&quot;, &quot;&lt;Plug&gt;GoVSMUp&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;M-l&gt;&quot;, &quot;&lt;Plug&gt;GoVSMRight&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;C-h&gt;&quot;, &quot;&lt;Plug&gt;GoVSDLeft&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;C-j&gt;&quot;, &quot;&lt;Plug&gt;GoVSDDown&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;C-k&gt;&quot;, &quot;&lt;Plug&gt;GoVSDUp&quot;, { noremap = true, silent = true })
map(&quot;x&quot;, &quot;&lt;C-l&gt;&quot;, &quot;&lt;Plug&gt;GoVSDRight&quot;, { noremap = true, silent = true })
end,
}
推荐度:★★★★★
主页:https://github.com/roobert/search-replace.nvim
简介:受够了手动输入吗?这款插件可以使用快捷键一键帮你输入这些内容。 这款插件是spectre插件的补充,你可以用这款插件或者spectre插件来达到全局文件替换的效果。
使用方式:快捷键使用
当前缓冲区:
<leader>rs:打开选择列表(个人不会用)
<leader>ro:打开Cmdline,自动帮你键入好了:%s//gcI
<leader>rw:打开Cmdline,自动帮你键入好了当前光标所在的word
<leader>rW:打开Cmdline,自动帮你键入好了当前光标所在WORD
<leader>re:...
<leader>rf:...
所有打开的缓冲区:同上,但是前缀是<leader>rb,只要多加一个b键即可 具体快捷键见下面的“快捷键配置”
配置:
{
&quot;roobert/search-replace.nvim&quot;,
lazy = true,
cmd = {
&quot;SearchReplaceSingleBufferVisualSelection&quot;,
&quot;SearchReplaceWithinVisualSelection&quot;,
&quot;SearchReplaceWithinVisualSelectionCWord&quot;,
&quot;SearchReplaceSingleBufferSelections&quot;,
&quot;SearchReplaceSingleBufferCWord&quot;,
&quot;SearchReplaceSingleBufferCWORD&quot;,
&quot;SearchReplaceSingleBufferCExpr&quot;,
&quot;SearchReplaceSingleBufferCFile&quot;,
&quot;SearchReplaceMultiBufferSelections&quot;,
&quot;SearchReplaceMultiBufferOpen&quot;,
&quot;SearchReplaceMultiBufferCWord&quot;,
&quot;SearchReplaceMultiBufferCWORD&quot;,
&quot;SearchReplaceMultiBufferCExpr&quot;,
&quot;SearchReplaceMultiBufferCFile&quot;,
},
config = function()
require(&quot;search-replace&quot;).setup({
default_replace_single_buffer_options = &quot;gcI&quot;,
default_replace_multi_buffer_options = &quot;egcI&quot;,
})
end,
}
快捷键配置:
-- search.replace.nvim config BEGIN
keymap[&quot;r&quot;] = {
name = &quot;SearchReplaceSingleBuffer&quot;,
s = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferSelections&lt;CR&gt;&quot;, &quot;SearchReplaceSingleBuffer [s]elction list&quot; },
o = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferOpen&lt;CR&gt;&quot;, &quot;[o]pen&quot; },
w = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferCWord&lt;CR&gt;&quot;, &quot;[w]ord&quot; },
W = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferCWORD&lt;CR&gt;&quot;, &quot;[W]ORD&quot; },
e = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferCExpr&lt;CR&gt;&quot;, &quot;[e]xpr&quot; },
f = { &quot;&lt;CMD&gt;SearchReplaceSingleBufferCFile&lt;CR&gt;&quot;, &quot;[f]ile&quot; },
b = {
name = &quot;SearchReplaceMultiBuffer&quot;,
s = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferSelections&lt;CR&gt;&quot;, &quot;SearchReplaceMultiBuffer [s]elction list&quot; },
o = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferOpen&lt;CR&gt;&quot;, &quot;[o]pen&quot; },
w = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferCWord&lt;CR&gt;&quot;, &quot;[w]ord&quot; },
W = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferCWORD&lt;CR&gt;&quot;, &quot;[W]ORD&quot; },
e = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferCExpr&lt;CR&gt;&quot;, &quot;[e]xpr&quot; },
f = { &quot;&lt;CMD&gt;SearchReplaceMultiBufferCFile&lt;CR&gt;&quot;, &quot;[f]ile&quot; },
},
}
lvim.keys.visual_block_mode[&quot;&lt;C-r&gt;&quot;] = [[&lt;CMD&gt;SearchReplaceSingleBufferVisualSelection&lt;CR&gt;]]
lvim.keys.visual_block_mode[&quot;&lt;C-s&gt;&quot;] = [[&lt;CMD&gt;SearchReplaceWithinVisualSelection&lt;CR&gt;]]
lvim.keys.visual_block_mode[&quot;&lt;C-b&gt;&quot;] = [[&lt;CMD&gt;SearchReplaceWithinVisualSelectionCWord&lt;CR&gt;]]
vim.o.inccommand = &quot;split&quot;
-- search.replace.nvim config END 推荐度:★★★★
主页:https://github.com/LeonHeidelbach/trailblazer.nvim
简介:一款很强大的临时轨迹标记插件,它可以使用快捷键保存你当前的位置,然后安心地把光标移到其它地方,之后再按快捷键按顺序跳回原来记录的位置。
使用方式:快捷键使用。
<A-s>:在当前行保存轨迹坐标
<A-d>:回到上一个保存的轨迹坐标,并删除该坐标
<A-o>:用quickfix打开所有轨迹坐标的列表
<A-L>:删除所有轨迹坐标
<A-p>:在上一个保存的轨迹坐标处粘贴
<A-P>:在所有保存的轨迹坐标处粘贴 更多快捷键见配置,以及Github文档。
配置:
{
&quot;LeonHeidelbach/trailblazer.nvim&quot;,
lazy = true,
keys = { &quot;&lt;A-s&gt;&quot;, &quot;&lt;A-d&gt;&quot; },
config = function()
-- local HOME = os.getenv(&quot;HOME&quot;)
require(&quot;trailblazer&quot;).setup({
auto_save_trailblazer_state_on_exit = false,
auto_load_trailblazer_state_on_enter = false,
-- custom_session_storage_dir = HOME .. &quot;/.local/share/trail_blazer_sessions/&quot;,
trail_options = {
mark_symbol = &quot;•&quot;, -- will only be used if trail_mark_symbol_line_indicators_enabled = true
newest_mark_symbol = &quot;&quot;, -- disable this mark symbol by setting its value to &quot;&quot;
cursor_mark_symbol = &quot;&quot;, -- disable this mark symbol by setting its value to &quot;&quot;
next_mark_symbol = &quot;&quot;, -- disable this mark symbol by setting its value to &quot;&quot;
previous_mark_symbol = &quot;&quot;, -- disable this mark symbol by setting its value to &quot;&quot;
},
mappings = {
nv = {
motions = {
new_trail_mark = &quot;&lt;A-s&gt;&quot;,
track_back = &quot;&lt;A-d&gt;&quot;,
peek_move_next_down = &quot;&lt;A-J&gt;&quot;,
peek_move_previous_up = &quot;&lt;A-K&gt;&quot;,
move_to_nearest = &quot;&lt;A-n&gt;&quot;,
toggle_trail_mark_list = &quot;&lt;A-o&gt;&quot;,
},
actions = {
delete_all_trail_marks = &quot;&lt;A-L&gt;&quot;,
paste_at_last_trail_mark = &quot;&lt;A-p&gt;&quot;,
paste_at_all_trail_marks = &quot;&lt;A-P&gt;&quot;,
set_trail_mark_select_mode = &quot;&lt;A-t&gt;&quot;,
switch_to_next_trail_mark_stack = &quot;&lt;A-.&gt;&quot;,
switch_to_previous_trail_mark_stack = &quot;&lt;A-,&gt;&quot;,
set_trail_mark_stack_sort_mode = &quot;&lt;A-S&gt;&quot;,
},
},
},
quickfix_mappings = { -- rename this to &quot;force_quickfix_mappings&quot; to completely override default mappings and not merge with them
-- nv = {
-- motions = {
-- qf_motion_move_trail_mark_stack_cursor = &quot;&lt;CR&gt;&quot;,
-- },
-- actions = {
-- qf_action_delete_trail_mark_selection = &quot;d&quot;,
-- qf_action_save_visual_selection_start_line = &quot;v&quot;,
-- },
-- alt_actions = {
-- qf_action_save_visual_selection_start_line = &quot;V&quot;,
-- },
-- },
-- v = {
-- actions = {
-- qf_action_move_selected_trail_marks_down = &quot;&lt;C-j&gt;&quot;,
-- qf_action_move_selected_trail_marks_up = &quot;&lt;C-k&gt;&quot;,
-- },
-- },
},
})
end,
}
推荐度:★★★★★
主页:https://github.com/chrisgrieser/nvim-recorder
简介:大幅简化和增强neovim自身的宏功能。允许你编辑、复制宏的内容以及设置断点
使用方法:快捷键使用
q:开始/结束录制宏
Q:执行当前选择的宏
<A-q>:切换宏槽位
cq:编辑当前槽位的宏
yq:复制当前槽位的宏
注:本配置仅使用了"u", "i", "o"三个槽位,如果需要更多槽位可以自行配置项。
配置:
{
&quot;chrisgrieser/nvim-recorder&quot;,
lazy = true,
keys = { &quot;q&quot;, &quot;Q&quot;, &quot;&lt;A-q&gt;&quot;, &quot;cq&quot;, &quot;yq&quot; },
config = function()
require(&quot;recorder&quot;).setup({
slots = { &quot;u&quot;, &quot;i&quot;, &quot;o&quot; },
mapping = {
startStopRecording = &quot;q&quot;,
playMacro = &quot;Q&quot;,
switchSlot = &quot;&lt;A-q&gt;&quot;,
editMacro = &quot;cq&quot;,
yankMacro = &quot;yq&quot;,
-- addBreakPoint = &quot;##&quot;,
},
})
end,
}
推荐度:★★★★
主页:https://github.com/chrisgrieser/nvim-various-textobjs
简介:为neovim新增很多textobjects,它们可以丰富你的快捷键选中、复制、修改等操作的体验。
使用方式:快捷键使用(以选中功能"v"来举例,可以替换为"c"(删除并修改)、"d"(删除)、"y"复制等)(可以替换为,表示"inner",表示"outer",如会选中包括本身的内容,而则不会)
viS:选中当前光标下的子word(如VimEnter,我们使用viw会选中整个VimEnter,但viS只会选中Enter或Vim)
vii:选中当前相同缩进的所有行
vR:选中当前相同缩进往后剩余的行
v%:选中当前光标下对应的括号结束位置
vr:选中剩余的段落
vgG:选中整个文件
v_:选中整行有字符的部分(除去空白字符)
viv:选中key-value的value部分
vik:选中key-value的key部分
vL:选中URL
vin:选中数字部分
v!:选中诊断部分(需要LSP)
vil:选中markdown的链接
viC:选中markdown的代码块部分
vic:选中css选择器
vi/:选中javascript的正则表达式pattern
viD:选中双中括号内容[[]]
注:可以修改的数量来改变我们使用textobjects时以当前光标为起点查找的行数。
配置:
{
&quot;chrisgrieser/nvim-various-textobjs&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
config = function()
require(&quot;various-textobjs&quot;).setup({
useDefaultKeymaps = true,
lookForwardLines = 10,
})
-- example: `an` for outer subword, `in` for inner subword
vim.keymap.set({ &quot;o&quot;, &quot;x&quot; }, &quot;aS&quot;, function()
require(&quot;various-textobjs&quot;).subword(false)
end)
vim.keymap.set({ &quot;o&quot;, &quot;x&quot; }, &quot;iS&quot;, function()
require(&quot;various-textobjs&quot;).subword(true)
end)
end,
}
推荐度:★★★★
主页:https://github.com/nvim-treesitter/nvim-treesitter-textobjects
简介:基于nvim-treesitter的textobjects,可以帮你选中class、function等语法内容
使用方式:快捷键使用,类似于nvim-various-textobjs(以选中模式举例)
选择
vaf:选中当前函数
vac:选中当前类内容
vas:选中当前scope
vad:选中当前条件(if..else)
跳转
]m:跳到下一个函数的开始处
]]:跳到下一个类的开始处
]s:跳到下一个scope的开始处
]z:跳到下一个fold的开始处
]M:跳到下一个函数的结尾处
][:跳到下一个类的结尾处
[m:跳到上一个函数的开始处
[[:跳到上一个类的开始处
[M:跳到上一个函数的结尾处
[]:跳到上一个类的结尾处
]d:跳到下一个条件
[d:跳到上一个条件
注:更多配置和用法见Github主页
配置:
{
&quot;nvim-treesitter/nvim-treesitter-textobjects&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
after = &quot;nvim-treesitter&quot;,
dependencies = { &quot;nvim-treesitter/nvim-treesitter&quot; },
config = function()
require(&quot;nvim-treesitter.configs&quot;).setup({
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
[&quot;af&quot;] = &quot;@function.outer&quot;,
[&quot;if&quot;] = &quot;@function.inner&quot;,
[&quot;ac&quot;] = &quot;@class.outer&quot;,
[&quot;ic&quot;] = { query = &quot;@class.inner&quot;, desc = &quot;Select inner part of a class region&quot; },
[&quot;as&quot;] = { query = &quot;@scope&quot;, query_group = &quot;locals&quot;, desc = &quot;Select language scope&quot; },
[&quot;id&quot;] = &quot;@conditional.inner&quot;,
[&quot;ad&quot;] = &quot;@conditional.outer&quot;,
},
selection_modes = {
[&quot;@parameter.outer&quot;] = &quot;v&quot;, -- charwise
[&quot;@function.outer&quot;] = &quot;V&quot;, -- linewise
[&quot;@class.outer&quot;] = &quot;&lt;c-v&gt;&quot;, -- blockwise
},
include_surrounding_whitespace = false,
},
move = {
enable = true,
set_jumps = true,
goto_next_start = {
[&quot;]m&quot;] = &quot;@function.outer&quot;,
[&quot;]]&quot;] = { query = &quot;@class.outer&quot;, desc = &quot;Next class start&quot; },
--
-- You can use regex matching and/or pass a list in a &quot;query&quot; key to group multiple queires.
[&quot;]o&quot;] = &quot;@loop.*&quot;,
-- [&quot;]o&quot;] = { query = { &quot;@loop.inner&quot;, &quot;@loop.outer&quot; } }
--
-- You can pass a query group to use query from `queries/&lt;lang&gt;/&lt;query_group&gt;.scm file in your runtime path.
-- Below example nvim-treesitter&#39;s `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm.
[&quot;]s&quot;] = { query = &quot;@scope&quot;, query_group = &quot;locals&quot;, desc = &quot;Next scope&quot; },
[&quot;]z&quot;] = { query = &quot;@fold&quot;, query_group = &quot;folds&quot;, desc = &quot;Next fold&quot; },
},
goto_next_end = {
[&quot;]M&quot;] = &quot;@function.outer&quot;,
[&quot;][&quot;] = &quot;@class.outer&quot;,
},
goto_previous_start = {
[&quot;[m&quot;] = &quot;@function.outer&quot;,
[&quot;[[&quot;] = &quot;@class.outer&quot;,
},
goto_previous_end = {
[&quot;[M&quot;] = &quot;@function.outer&quot;,
[&quot;[]&quot;] = &quot;@class.outer&quot;,
},
-- Below will go to either the start or the end, whichever is closer.
-- Use if you want more granular movements
-- Make it even more gradual by adding multiple queries and regex.
goto_next = {
[&quot;]d&quot;] = &quot;@conditional.outer&quot;,
},
goto_previous = {
[&quot;[d&quot;] = &quot;@conditional.outer&quot;,
},
},
swap = {
enable = false,
swap_next = {
[&quot;&lt;leader&gt;a&quot;] = &quot;@parameter.inner&quot;,
},
swap_previous = {
[&quot;&lt;leader&gt;A&quot;] = &quot;@parameter.inner&quot;,
},
},
},
})
local ts_repeat_move = require(&quot;nvim-treesitter.textobjects.repeatable_move&quot;)
-- Repeat movement with ; and ,
-- ensure ; goes forward and , goes backward regardless of the last direction
vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;;&quot;, ts_repeat_move.repeat_last_move_next)
vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;,&quot;, ts_repeat_move.repeat_last_move_previous)
-- vim way: ; goes to the direction you were moving.
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;;&quot;, ts_repeat_move.repeat_last_move)
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;,&quot;, ts_repeat_move.repeat_last_move_opposite)
-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;f&quot;, ts_repeat_move.builtin_f)
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;F&quot;, ts_repeat_move.builtin_F)
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;t&quot;, ts_repeat_move.builtin_t)
-- vim.keymap.set({ &quot;n&quot;, &quot;x&quot;, &quot;o&quot; }, &quot;T&quot;, ts_repeat_move.builtin_T)
end,
}
推荐度:★★★
主页:https://github.com/RRethy/nvim-treesitter-textsubjects
简介:根据光标位置自动决定要选中什么textobject
使用方式:快捷键使用(以v选中模式举例)
v.:根据光标位置,智能选择
v,:选中上一次选中的范围
v;:选中容器外围
vi;:选中容器内
注:在某些情况下貌似有点卡,可能是因为nvim-treesitter的树比较长的缘故,但是小文件还是很快的
配置:
{
&quot;RRethy/nvim-treesitter-textsubjects&quot;,
lazy = true,
event = { &quot;User FileOpened&quot; },
after = &quot;nvim-treesitter&quot;,
dependencies = { &quot;nvim-treesitter/nvim-treesitter&quot; },
config = function()
require(&quot;nvim-treesitter.configs&quot;).setup({
textsubjects = {
enable = true,
prev_selection = &quot;,&quot;,
keymaps = {
[&quot;.&quot;] = &quot;textsubjects-smart&quot;,
[&quot;;&quot;] = &quot;textsubjects-container-outer&quot;,
[&quot;i;&quot;] = &quot;textsubjects-container-inner&quot;,
},
},
})
end,
},
在下创建一个目录,然后在里面创建一个,配置好指定格式的内容,之后编辑对应的json文件就可以为对应的文件类型添加snippets了
参照 https://github.com/ADkun/my-lvim-config 的目录
在Mason插件中下载的formatter和linter,需要我们手动将它们对应到文件类型上。 以下是我的配置项,可以参考配置。
local formatters = require(&quot;lvim.lsp.null-ls.formatters&quot;)
formatters.setup({
{ command = &quot;stylua&quot; },
{
command = &quot;black&quot;,
filetypes = { &quot;python&quot; },
},
{
command = &quot;prettier&quot;,
extra_args = { &quot;--print-width&quot;, &quot;100&quot; },
filetypes = { &quot;typescript&quot;, &quot;typescriptreact&quot; },
},
})
local linters = require(&quot;lvim.lsp.null-ls.linters&quot;)
linters.setup({
{ command = &quot;flake8&quot;, filetypes = { &quot;python&quot; } },
{
command = &quot;shellcheck&quot;,
args = { &quot;--severity&quot;, &quot;warning&quot; },
},
{
command = &quot;luacheck&quot;,
filetypes = { &quot;lua&quot; },
},
-- {
-- command = &quot;cpplint&quot;,
-- filetypes = { &quot;cpp&quot;, &quot;c&quot; },
-- },
})