packer.nvim: A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
nvim-tree: A file explorer tree for neovim written in lua
⚠️ nvim-tree 依赖 Nerd Fonts Nerd Fonts ➤➤➤
💾 安装插件
编辑 plugins.lua 文件
returnrequire('packer').startup(function(use)-- packer插件本身
use 'wbthomason/packer.nvim'-- catppuccin 主题use{"catppuccin/nvim", as ="catppuccin"}-- nvim-tree 文件浏览器use{'nvim-tree/nvim-tree.lua',
requires ={'nvim-tree/nvim-web-devicons',-- optional, for file icons},
tag ='nightly'-- optional, updated every week. (see issue #1193)}end)
bufferline.nvim: A snazzy 💅 buffer line (with tabpage integration) for Neovim built using lua.
💾 安装插件 编辑 plugins.lua 文件
returnrequire('packer').startup(function(use)-- packer插件本身
use 'wbthomason/packer.nvim'-- catppuccin 主题use{"catppuccin/nvim", as ="catppuccin"}-- nvim-tree 文件浏览器use{'nvim-tree/nvim-tree.lua',
requires ={'nvim-tree/nvim-web-devicons',-- optional, for file icons},
tag ='nightly'-- optional, updated every week. (see issue #1193)}-- buffer 管理use{'akinsho/bufferline.nvim', tag ="v3.*", requires ='nvim-tree/nvim-web-devicons'}end)
local status_ok, bufferline =pcall(require,"bufferline")ifnot status_ok then
vim.notify("bufferline not found!")returnend
vim.opt.termguicolors =true
bufferline.setup({
options ={
mode ="buffers",-- set to "tabs" to only show tabpages instead
numbers ="ordinal",-- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,--- @deprecated, please specify numbers as a function to customize the styling-- number_style = "superscript", --| "subscript" | "" | { "none", "subscript" }, -- buffer_id at index 1, ordinal at index 2
close_command ="bdelete! %d",-- can be a string | function, see "Mouse actions"
right_mouse_command ="bdelete! %d",-- can be a string | function, see "Mouse actions"
left_mouse_command ="buffer %d",-- can be a string | function, see "Mouse actions"
middle_mouse_command =nil,-- can be a string | function, see "Mouse actions"-- NOTE: this plugin is designed with this icon in mind,-- and so changing this is NOT recommended, this is intended-- as an escape hatch for people who cannot bear it for whatever reason--
indicator ={
icon ='▎',-- this should be omitted if indicator style is not 'icon'
style ='icon',},
buffer_close_icon ='',
modified_icon ='●',
close_icon ='x',
left_trunc_marker ='',
right_trunc_marker ='',--- name_formatter can be used to change the buffer's label in the bufferline.--- Please note some names can/will break the--- bufferline so use this at your discretion knowing that it has--- some limitations that will *NOT* be fixed.
name_formatter =function(buf)-- buf contains a "name", "path" and "bufnr"-- remove extension from markdown files for exampleif buf.name:match('%.md')thenreturn vim.fn.fnamemodify(buf.name,':t:r')endend,
max_name_length =18,
max_prefix_length =15,-- prefix used when a buffer is de-duplicated
tab_size =18,
diagnostics =false,--| "nvim_lsp" | "coc",
diagnostics_update_in_insert =false,
diagnostics_indicator =function(count, level, diagnostics_dict, context)return"("..count..")"end,-- NOTE: this will be called a lot so don't do any heavy processing here
custom_filter =function(buf_number, buf_numbers)-- filter out filetypes you don't want to seeif vim.bo[buf_number].filetype ~="<i-dont-want-to-see-this>"thenreturntrueend-- filter out by buffer nameif vim.fn.bufname(buf_number)~="<buffer-name-I-dont-want>"thenreturntrueend-- filter out based on arbitrary rules-- e.g. filter out vim wiki buffer from tabline in your work repoif vim.fn.getcwd()=="<work-repo>"and vim.bo[buf_number].filetype ~="wiki"thenreturntrueend-- filter out by it's index number in list (don't show first buffer)if buf_numbers[1]~= buf_number thenreturntrueendend,
offsets ={{filetype ="NvimTree", text ="File Explorer", text_align="center"}},-- | function , text_align = "left" | "center" | "right"}},
show_buffer_icons =true,--| false, -- disable filetype icons for buffers
show_buffer_close_icons =true,--| false,
show_close_icon =true,--| false,
show_tab_indicators =true,-- | false,
persist_buffer_sort =true,-- whether or not custom sorted buffers should persist-- can also be a table containing 2 custom separators-- [focused and unfocused]. eg: { '|', '|' }
separator_style ="thin",--| "slant" | "thick" | "thin" | { 'any', 'any' },
enforce_regular_tabs =false,--| true,
always_show_bufferline =true,-- | false,
sort_by ='directory',-- ,'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b)-- -- add custom logic-- return buffer_a.modified > buffer_b.modified-- end}})
telescope.nvim is a highly extendable fuzzy finder over lists. Built on the latest awesome features from neovim core. Telescope is centered around modularity, allowing for easy customization. %}
💾 安装插件 编辑 plugins.lua 文件
returnrequire('packer').startup(function(use)-- packer插件本身
use 'wbthomason/packer.nvim'-- catppuccin 主题use{"catppuccin/nvim", as ="catppuccin"}-- nvim-tree 文件浏览器use{'nvim-tree/nvim-tree.lua',
requires ={'nvim-tree/nvim-web-devicons',-- optional, for file icons},
tag ='nightly'-- optional, updated every week. (see issue #1193)}-- buffer 管理use{'akinsho/bufferline.nvim', tag ="v3.*", requires ='nvim-tree/nvim-web-devicons'}-- telescope 搜索模块use{'nvim-telescope/telescope.nvim', tag ='0.1.0',-- or , branch = '0.1.x',
requires ={{'nvim-lua/plenary.nvim'}}}end)
nvim-treesitter: Nvim Treesitter configurations and abstraction layer.
💾 安装插件 编辑 plugins.lua 文件
returnrequire('packer').startup(function(use)-- packer插件本身
use 'wbthomason/packer.nvim'-- catppuccin 主题use{"catppuccin/nvim", as ="catppuccin"}-- nvim-tree 文件浏览器use{'nvim-tree/nvim-tree.lua',
requires ={'nvim-tree/nvim-web-devicons',-- optional, for file icons},
tag ='nightly'-- optional, updated every week. (see issue #1193)}-- buffer 管理use{'akinsho/bufferline.nvim', tag ="v3.*", requires ='nvim-tree/nvim-web-devicons'}-- telescope 搜索模块use{'nvim-telescope/telescope.nvim', tag ='0.1.0',-- or , branch = '0.1.x',
requires ={{'nvim-lua/plenary.nvim'}}}-- nvim-treesitter 语法高亮
use 'nvim-treesitter/nvim-treesitter',{'do':':TSUpdate'}end)
local status_ok, configs =pcall(require,"nvim-treesitter.configs")ifnot status_ok then
vim.notify("treesitter not found!")returnend
configs.setup{
ensure_installed ={"cpp","c","python","go","markdown","json","yaml","html","lua"},-- one of "all", "maintained" (parsers with maintainers), or a list of languages
sync_install =false,-- install languages synchronously (only applied to `ensure_installed`)
ignore_install ={""},-- List of parsers to ignore installing
highlight ={
enable =true,-- false will disable the whole extension
disable ={""},-- list of language that will be disabled
additional_vim_regex_highlighting =false,},
indent ={ enable =true, disable ={"yaml"}},
context_commentstring ={
enable =true,
config ={-- Languages that have a single comment style
typescript ="// %s",
css ="/* %s */",
scss ="/* %s */",
html ="<!-- %s -->",
svelte ="<!-- %s -->",
vue ="<!-- %s -->",
json ="",},},-- textobjects extension settings-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects
textobjects ={
swap ={
enable =false,},
select ={
enable =true,-- Automatically jump forward to textobj, similar to targets.vim
lookahead =true,
keymaps ={-- You can use the capture groups defined in textobjects.scm["af"]="@function.outer",["if"]="@function.inner",["ac"]="@class.outer",["ic"]="@class.inner",},},
move ={
enable =true,
set_jumps =false,-- whether to set jumps in the jumplist
goto_next_start ={["]]"]="@function.outer",-- ["]["] = "@function.outer",},
goto_next_end ={["]["]="@function.outer",-- ["]["] = "@class.outer",},
goto_previous_start ={["[["]="@function.outer",-- ["[]"] = "@function.outer",},
goto_previous_end ={["[]"]="@function.outer",-- ["[]"] = "@class.outer",},},
lsp_interop ={
enable =false,
border ='none',
peek_definition_code ={["<leader>pf"]="@function.outer",["<leader>pF"]="@class.outer",},},},
textsubjects ={
enable =false,
keymaps ={["."]="textsubjects-smart",[";"]="textsubjects-big"},},
playground ={
enable =false,
disable ={},
updatetime =25,-- Debounced time for highlighting nodes in the playground from source code
persist_queries =false,-- Whether the query persists across vim sessions
keybindings ={
toggle_query_editor ="o",
toggle_hl_groups ="i",
toggle_injected_languages ="t",
toggle_anonymous_nodes ="a",
toggle_language_display ="I",
focus_language ="f",
unfocus_language ="F",
update ="R",
goto_node ="<cr>",
show_help ="?",},},
rainbow ={
enable =false,
extended_mode =true,-- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
max_file_lines =1000,-- Do not enable for files with more than 1000 lines, int},
autotag ={ enable =false},-- matchup plugin-- https://github.com/andymass/vim-matchup
matchup ={
enable =false,-- mandatory, false will disable the whole extension-- disable = { "c", "ruby" }, -- optional, list of language that will be disabled-- [options]},-- autopairs plugin
autopairs ={
enable =false,},}-- 开启 Folding 模块
vim.opt.foldmethod ="expr"
vim.opt.foldexpr ="nvim_treesitter#foldexpr()"-- 默认不要折叠-- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
vim.opt.foldlevel =99
mason.nvim: Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
安装 LSP 服务器
💾 安装插件
编辑 plugins.lua 文件
returnrequire('packer').startup(function(use)-- packer插件本身
use 'wbthomason/packer.nvim'-- catppuccin 主题use{"catppuccin/nvim", as ="catppuccin"}-- nvim-tree 文件浏览器use{'nvim-tree/nvim-tree.lua',
requires ={'nvim-tree/nvim-web-devicons',-- optional, for file icons},
tag ='nightly'-- optional, updated every week. (see issue #1193)}-- lspuse{"williamboman/mason.nvim","williamboman/mason-lspconfig.nvim","neovim/nvim-lspconfig",}end)
local status_ok, mason =pcall(require,"mason")ifnot status_ok then
vim.notify("mason not found!")returnendlocal status_ok, mason_lspconfig =pcall(require,"mason-lspconfig")ifnot status_ok then
vim.notify("mason-lspconfig not found!")returnendlocal status_ok, lspconfig =pcall(require,"lspconfig")ifnot status_ok then
vim.notiry("lspconfig not found")returnend
mason.setup({
ui ={
icons ={
package_installed ="✓",
package_pending ="➜",
package_uninstalled ="✗"}}})
mason_lspconfig.setup({
ensure_installed ={"sumneko_lua","rust_analyzer","gopls","jsonls","tsserver","pyright"},
automatic_installation =true,})
mason_lspconfig.setup_handlers{-- The first entry (without a key) will be the default handler-- and will be called for each installed server that doesn't have-- a dedicated handler.function(server_name)-- default handler (optional)require("lspconfig")[server_name].setup{}end,-- Next, you can provide a dedicated handler for specific servers.-- For example, a handler override for the `rust_analyzer`:["sumneko_lua"]=function()
lspconfig.sumneko_lua.setup{
settings ={
Lua ={
diagnostics ={
globals ={"vim"}}}}}end,}