Merge arch-refactor into main

This commit is contained in:
QQ 2026-06-17 14:47:13 +08:00
commit 293a5a8689
27 changed files with 823 additions and 596 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
lazy-lock.json lazy-lock.json
nvim.log

172
README.md Normal file
View File

@ -0,0 +1,172 @@
# Neovim 配置
基于 Neovim 0.12+lazy.nvim 管理插件,支持原生和 VSCode Neovim 双模式。
## 目录结构
```
init.lua # 入口:安装 lazy.nvim → keymaps → 分支判断
lua/
G.lua # 全局工具单例vim API 别名 + 映射/命令/自动命令封装)
keymap.lua # 基础快捷键
options.lua # vim.opt 基础设置
vsc.lua # VSCode Neovim 模式下的精简启动(仅编辑插件)
plugs.lua # 插件聚合器10 个模块)
plugs/
nvim-lspconfig.lua # LSP 核心7 个 server 注册 + LSP 快捷键
mason.lua # LSP server 自动安装Mason
nvim-cmp.lua # 补全引擎nvim-cmp + vsnip + lspkind + 命令行补全)
treesitter.lua # 语法高亮 + 自动安装 parser
symbols-outline.lua # 代码大纲侧边栏
winbar.lua # 顶部文件路径 + 函数标签
nvimtree.lua # 文件树
theme.lua # 主题tokyonight+ 状态栏lualine+ 标签栏tabline
edit-plugs.lua # 编辑增强fzf/surround/wildfire/多光标/对齐/Copilot/折叠/hop
dev.lua # 开发工具colorizer/go.nvim/conda/toggleterm
lsp/
lua.lua # Lua LSPLuaJIT + 全局变量声明)
c.lua # C/C++ LSPclangd+ :R 编译运行
bash.lua # Bash LSP + :R 运行
go.lua # Go LSPgopls+ :R / :Rgin 运行
basedpyright.lua # Python LSPbasedpyright+ :R 运行
yaml.lua # YAML LSP + GitHub Workflow schema
json.lua # JSON LSP
snippets/ # 代码片段C/Go/JSON/Lua
```
## 启动流程
```
G.lua → 克隆/定位 lazy.nvim → keymap.lua →
若 VSCode 环境 → vsc.lua仅编辑插件
若原生 Neovim → options.lua → lazy.setup(plugs.lua)
```
## 插件总表(~28 个)
| 分类 | 插件 | 用途 |
|------|------|------|
| LSP | nvim-lspconfig | LSP 客户端配置 |
| LSP | Mason + mason-lspconfig | LSP server 自动下载 |
| LSP | lua_ls, clangd, bashls, gopls, basedpyright, yamlls, jsonls | 7 种语言 LSP |
| 补全 | nvim-cmp + cmp-nvim-lsp + cmp-buffer + cmp-path + cmp-cmdline | 补全引擎 |
| 补全 | vim-vsnip + cmp-vsnip | 代码片段引擎 |
| 补全 | lspkind-nvim | 补全图标 |
| 语法 | nvim-treesitter | 语法高亮 + 缩进检测 |
| 语法 | nvim-autopairs | 自动括号配对 |
| 语法 | nvim-hlchunk | 括号层级和缩进色块 |
| 主题 | tokyonight.nvim | 配色方案 |
| UI | lualine.nvim | 状态栏 |
| UI | tabline.nvim | 顶部标签栏 |
| UI | winbar.nvim | 顶部文件名 + 函数路径 |
| UI | nvim-tree.lua | 侧边文件树 |
| UI | symbols-outline.nvim | 代码大纲 |
| UI | colorizer | 颜色值可视化 |
| 编辑 | nvim-fzf | 模糊搜索 |
| 编辑 | vim-surround | 环绕字符操作cs/ds/ys |
| 编辑 | wildfire.vim | 选区自动扩大/缩小 |
| 编辑 | vim-multiple-cursors | 多光标编辑 |
| 编辑 | vim-easy-align | 对齐排版 |
| 编辑 | hop.nvim | 快速跳转(替代 f/F/t/T |
| 编辑 | nvim-ufo | 现代折叠treesitter 驱动) |
| AI | copilot.vim | GitHub Copilot 行内补全 |
| 语言 | go.nvim | Go 开发增强test/coverage 等) |
| 语言 | nvim-conda | Conda 环境切换 |
| 终端 | toggleterm.nvim | 浮层终端 |
## 快捷键速查
### 基础操作
| 键 | 模式 | 功能 |
|----|------|------|
| `<leader>nh` | n | 清除搜索高亮 |
| `<leader>rp` | n | 全局替换 `:%s/` |
| `<leader>y` / `p` / `v` | n | 全文件复制/粘贴/全选 |
| `<A-h>` / `<A-l>` | n | 切换左右标签页 |
| `<c-j/h/k/l>` | n | 窗口间跳转 |
| `<c-c>` / `<c-q>` | n | 关闭窗口 / 强制关闭 |
| `<c-S>` | n | sudo 强制保存 |
| `<cs-y>` | v | 复制到系统剪切板 |
| `<c-e>` | n | 文件树开关 |
| `<cs-o>` | n | 代码大纲开关 |
| `<c-t>` | n/i | 终端开关 |
| `<C-i>` | n | Reasonix AI自适应分屏横屏→下方竖屏→右侧 |
| `<up/down/left/right>` | n | 调整窗口大小 |
### LSP
| 键 | 模式 | 功能 |
|----|------|------|
| `gd` | n | 跳转到定义 |
| `gh` | n | 悬浮文档 |
| `gD` | n | 跳转到声明 |
| `gi` | n | 跳转到实现 |
| `gr` | n | 查找引用 |
| `<cs-r>` | n | 重命名符号 |
| `<cs-i>` | n | 代码格式化 |
### 语言运行 `:R`
| 语言 | 命令 |
|------|------|
| C/C++ | 编译 → 运行 → 删二进制 |
| Bash | `sh %` |
| Go | `go run %``:Rgin` 运行 `main.go` |
| Python | `python3 %` |
### 补全(插入模式)
| 键 | 功能 |
|----|------|
| `<C-n>` / `<C-p>` | 选择补全项 / snippet 占位跳转 |
| `<CR>`(未选择时) | 换行 |
| `<CR>`(选择后) | 确认补全 |
| `Tab` | Copilot 接受建议 |
### 命令栏 / 搜索栏补全
| 键 | 功能 |
|----|------|
| `Tab` / `S-Tab` | 选择补全项 |
| `<CR>`(未选择时) | 直接执行命令/搜索 |
| `<CR>`(选择后) | 确认补全 |
### 编辑
| 键 | 模式 | 功能 |
|----|------|------|
| `f` / `F` / `t` / `T` | n | hop 行内跳转(覆盖原生) |
| `<c-f>` | n | hop 双字符跳转 |
| `ga` / `=` | v | EasyAlign 对齐 |
| `gc` / `gcc` | n | 注释切换Neovim 0.12 内置) |
| `zc` / `zo` / `za` / `zR` | n | 折叠ufo |
### 文件树内
| 键 | 功能 |
|----|------|
| `v` | 垂直分屏打开 |
| `s` | 水平分屏打开 |
## LSP 说明
- 使用 Neovim 0.11+ 新 API`vim.lsp.config` / `vim.lsp.enable`
- `capabilities``cmp_nvim_lsp` 统一在 `nvim-lspconfig.lua` 注入,各语言文件不重复 require
- `basedpyright` 替代了 `pyright`(类型检查更强)
- Mason 自动安装bashls、lua_ls、jsonls、yamllsbasedpyright 需手动装)
- Treesitter 关闭了 txt parser禁用了 Go恢复中由 go.nvim 处理)
## 安装
```bash
# 克隆到 Neovim 配置目录
git clone https://git.qyhhh.top/newbie/nvim.git ~/.config/nvim
# 首次启动会自动安装 lazy.nvim 及全部插件
nvim
```
## 许可
MIT

View File

@ -1,47 +1,34 @@
G = require('G') G = require('G')
-- lazy.nvim 必须在 VSCode 和原生环境都可用原生用它装插件VSCode 的 vsc.lua 也需要 require('lazy')
if not G.g.vscode then local lazypath = G.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not G.loop.fs_stat(lazypath) then
local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not G.loop.fs_stat(lazypath) then
G.fn.system({ G.fn.system({
"git", 'git',
"clone", 'clone',
"--filter=blob:none", '--filter=blob:none',
"https://github.com/folke/lazy.nvim.git", 'https://github.com/folke/lazy.nvim.git',
"--branch=stable", '--branch=stable',
lazypath, lazypath,
}) })
end
G.opt.rtp:prepend(lazypath)
-- keymap 在两个环境都加载(基础键位都不依赖插件)
require('keymap')
G.fn.system({ if G.g.vscode then
"git", -- VSCode Neovim 模式:只加载编辑插件,不加载 LSP/补全/主题/选项
"config",
"--global",
"credential.helper",
"store",
})
end
G.opt.rtp:prepend(lazypath)
require("keymap")
if G.g.vscode then
require('vscode') require('vscode')
else else
require("options") require('options')
local clone_prefix = G.use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git" local clone_prefix = G.use_ssh and 'git@github.com:%s.git' or 'https://github.com/%s.git'
require("lazy").setup( require('lazy').setup(
require('plugs'), { require('plugs'), {
lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json", lockfile = G.fn.stdpath('data') .. '/lazy/lazy-lock.json',
git = { git = {
url_format = clone_prefix, url_format = clone_prefix,
} }
} }
) )
end
end end

View File

@ -13,28 +13,16 @@ G.lb = vim.lsp.buf
G.dic = vim.diagnostic G.dic = vim.diagnostic
G.cgp = vim.nvim_create_augroup G.cgp = vim.nvim_create_augroup
-- 批量设置键映射3 元素自动加 { noremap = true }4 元素用传入的 opts
function G.map(maps) function G.map(maps)
for _, map in pairs(maps) do for _, map in pairs(maps) do
if #map == 3 then vim.keymap.set(map[1], map[2], map[3], map[4] or { noremap = true })
vim.keymap.set(map[1], map[2], map[3], { noremap = true })
elseif #map == 4 then
vim.keymap.set(map[1], map[2], map[3], map[4])
else
print("太多变量了")
end
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
end end
end end
function G.delmap(maps) function G.delmap(maps)
for _, map in pairs(maps) do for _, map in pairs(maps) do
if #map == 2 then vim.keymap.del(map[1], map[2], map[3] or {})
vim.keymap.del(map[1], map[2], {})
elseif #map == 3 then
vim.keymap.del(map[1], map[2], map[3])
else
print("太多变量了")
end
end end
end end
@ -54,6 +42,15 @@ function G.au(even, opts)
return G.api.nvim_create_autocmd(even, opts) return G.api.nvim_create_autocmd(even, opts)
end end
-- :R 命令工厂:在下方分屏开终端运行指定命令,省去 5 个 LSP 文件的重复代码
function G.run_cmd(cmd)
return function()
G.cmd [[set splitbelow | sp]]
G.cmd("term " .. cmd)
G.cmd [[resize 10 | startinsert]]
end
end
G.g.mapleader = ' ' G.g.mapleader = ' '
return G return G

View File

@ -1,46 +1,40 @@
local opt = { noremap = true }
-- base -- base
G.map({ G.map({
{ 'n', '<leader>nh', ':nohlsearch<CR>', opt }, { 'n', '<leader>nh', ':nohlsearch<CR>' },
{ 'n', '<leader>rp', ':%s/', opt }, { 'n', '<leader>rp', ':%s/' },
{ 'v', 'L', '$', opt }, { 'v', 'L', '$' },
{ 'v', 'H', '^', opt }, { 'v', 'H', '^' },
{ 'n', 'L', '$', opt }, { 'n', 'L', '$' },
{ 'n', 'H', '^', opt }, { 'n', 'H', '^' },
{ 'v', '>', '>gv', opt }, { 'v', '>', '>gv' },
{ 'v', '<', '<gv', opt }, { 'v', '<', '<gv' },
{ 'n', '>', '>>', opt }, { 'n', '>', '>>' },
{ 'n', '<', '<<', opt }, { 'n', '<', '<<' },
{ 'n', '?', ':set hlsearch<CR>?', opt }, { 'n', '?', ':set hlsearch<CR>?' },
{ 'n', '/', ':set hlsearch<CR>/', opt }, { 'n', '/', ':set hlsearch<CR>/' },
{ 'n', '<A-l>', ':tabn<CR>', opt }, { 'n', '<A-l>', ':tabn<CR>' },
{ 'n', '<A-h>', ':tabp<CR>', opt }, { 'n', '<A-h>', ':tabp<CR>' },
{ 'n', '<c-j>', '<c-w>j' },
{ 'n', '<c-h>', '<c-w>h' },
{ 'n', '<c-k>', '<c-w>k' },
{ 'n', '<c-l>', '<c-w>l' },
{ 'n', '<c-j>', '<c-w>j', opt }, { 'n', '<c-c>', ':q<CR>' },
{ 'n', '<c-h>', '<c-w>h', opt }, { 'n', '<c-S>', ':w !sudo tee %<CR>' },
{ 'n', '<c-k>', '<c-w>k', opt }, { 'n', '<c-q>', ':q!<CR>' },
{ 'n', '<c-l>', '<c-w>l', opt }, { 'v', '<cs-y>', '"+y' },
{ 'n', '<leader>y', 'ggyG' },
{ 'n', '<leader>p', 'ggpG' },
{ 'n', '<leader>v', 'ggVG' },
{ 'n', '<c-c>', ':q<CR>', opt }, { 'n', '<up>', ':res -5<CR>' },
{ 'n', '<c-S>', ':w !sudo tee %<CR>', opt }, { 'n', '<down>', ':res +5<CR>' },
{ 'n', '<c-q>', ':q!<CR>', opt }, { 'n', '<left>', ':vertical resize -5<CR>' },
{ 'v', '<cs-y>', '"+y', opt }, { 'n', '<right>', ':vertical resize +5<CR>' },
{ 'n', '<leader>y', 'ggyG', opt },
{ 'n', '<leader>p', 'ggpG', opt },
{ 'n', '<leader>v', 'ggVG', opt },
{ 'n', '<up>', ':res -5<CR>', opt },
{ 'n', '<down>', ':res +5<CR>', opt },
{ 'n', '<left>', ':vertical resize -5<CR>', opt },
{ 'n', '<right>', ':vertical resize +5<CR>', opt },
}) })

View File

@ -1,5 +1,5 @@
return { return {
-- capabilities = require("cmp_nvim_lsp").default_capabilities(), -- basedpyrightpyright 的增强分支类型检查更强。capabilities 由 nvim-lspconfig.lua 统一注入
settings = { settings = {
basedpyright = { basedpyright = {
analysis = { analysis = {
@ -11,12 +11,6 @@ return {
}, },
}, },
on_attach = function() on_attach = function()
G.api.nvim_create_user_command('R', function() G.api.nvim_create_user_command('R', G.run_cmd('python3 %'), {})
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term python3 %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
end end
} }

View File

@ -1,11 +1,5 @@
return{ return{
on_attach = function() on_attach = function()
G.api.nvim_create_user_command('R', function() G.api.nvim_create_user_command('R', G.run_cmd('sh %'), {})
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term sh %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
end end
} }

View File

@ -1,11 +1,5 @@
return { return {
on_attach = function() on_attach = function()
G.api.nvim_create_user_command('R', function() G.api.nvim_create_user_command('R', G.run_cmd('g++ "%" -o "%<" && ./"%<" && rm "%<"'), {})
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term g++ "%" -o "%<" && ./"%<" && rm "%<"]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
end end
} }

View File

@ -1,18 +1,7 @@
return { return {
-- gopls + :Rgo run %+ :Rgingo run ./main.go主入口专用
on_attach = function() on_attach = function()
G.api.nvim_create_user_command('R', function() G.api.nvim_create_user_command('R', G.run_cmd('go run %'), {})
G.cmd [[set splitbelow]] G.api.nvim_create_user_command('Rgin', G.run_cmd('go run ./main.go'), {})
G.cmd [[sp]]
G.cmd [[term go run %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('Rgin', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term go run ./main.go]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
end end
} }

View File

@ -1,4 +1 @@
return { return {}
on_attach = function()
end
}

View File

@ -5,8 +5,6 @@ table.insert(runtime_path, "lua/?/init.lua")
return { return {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
settings = { settings = {
Lua = { Lua = {

View File

@ -1,5 +1,4 @@
return { return {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
settings = { settings = {
yaml = { yaml = {
schemas = { schemas = {

View File

@ -1,4 +1,3 @@
--
G.opt.ttimeout = true G.opt.ttimeout = true
G.opt.ttimeoutlen = 100 G.opt.ttimeoutlen = 100
@ -8,7 +7,6 @@ G.opt.rnu = true
G.opt.scrolloff = 999 G.opt.scrolloff = 999
-- 自动保存 -- 自动保存
G.opt.autowrite = true
G.opt.autowriteall = true G.opt.autowriteall = true
-- tab键 -- tab键
@ -31,24 +29,18 @@ G.opt.ignorecase = true
G.opt.incsearch = true G.opt.incsearch = true
-- 不换行 -- 不换行
G.opt.textwidth = 999 G.opt.textwidth = 0
G.opt.wrap = false G.opt.wrap = false
-- 文件判断 -- 文件判断
G.cmd("filetype plugin indent on") G.cmd("filetype plugin indent on")
-- 取消换行注释 -- 取消换行注释o 和 O 不自动续注释回车继续续注释一次设定formatoptions 不会变)
G.au({ "BufEnter" }, { G.opt.formatoptions = G.opt.formatoptions - "o" + "r"
pattern = { "*" },
callback = function()
-- vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" }
G.opt.formatoptions = G.opt.formatoptions
- "o" -- O and o, don't continue comments
+ "r" -- But do continue when pressing enter.
end,
})
-- 进入插入模式时自动关搜索高亮(个人偏好:打字时不想被高亮干扰)
G.au({ "InsertEnter" }, { G.au({ "InsertEnter" }, {
pattern = { "*" }, pattern = { "*" },
callback = function() callback = function()
@ -56,6 +48,7 @@ G.au({ "InsertEnter" }, {
end, end,
}) })
-- .code-snippets 文件强制识别为 JSON方便编辑否则无法语法高亮
G.au({ "VimEnter", "BufEnter" }, { G.au({ "VimEnter", "BufEnter" }, {
pattern = { "*.code-snippets" }, pattern = { "*.code-snippets" },
callback = function() callback = function()
@ -63,14 +56,8 @@ G.au({ "VimEnter", "BufEnter" }, {
end, end,
}) })
-- G.au({
-- {"CmdlineEnter"},
-- {
-- if index
-- }
-- })
-- 自动检测 Conda Python 环境,优先用 conda 里的 python
local function isempty(s) local function isempty(s)
return s == nil or s == "" return s == nil or s == ""
end end

View File

@ -1,32 +1,13 @@
return { return {
require('plugs.nvim-lspconfig'), require('plugs.nvim-lspconfig'),
require('plugs.nvimtree'), -- nvimtree require('plugs.mason'),
require('plugs.theme'), -- theme require('plugs.symbols-outline'),
require("plugs.edit-plugs"), require('plugs.nvim-cmp'),
require("plugs.dev"), require('plugs.treesitter'),
require('plugs.winbar'),
require('plugs.nvimtree'),
-- leetcode刷题 require('plugs.theme'),
-- { require('plugs.edit-plugs'),
-- "kawre/leetcode.nvim", require('plugs.dev'),
-- build = ":TSUpdate html", require('plugs.QQdock'),
-- dependencies = {
-- "nvim-telescope/telescope.nvim",
-- "nvim-lua/plenary.nvim", -- telescope 所需
-- "MunifTanjim/nui.nvim",
-- -- 可选
-- "nvim-treesitter/nvim-treesitter",
-- "rcarriga/nvim-notify",
-- "nvim-tree/nvim-web-devicons",
-- },
-- opts = {
-- -- 配置放在这里
-- cn = {
-- enabled = true,
-- },
-- },
-- },
} }

31
lua/plugs/QQdock.lua Normal file
View File

@ -0,0 +1,31 @@
-- QQdock.nvim — 持久化自适应终端
-- 远程仓库https://git.qyhhh.top/newbie/QQdock.nvim
-- 本地临时副本lua/QQdock/init.lua根分区只读期间使用
--
-- 恢复读写后操作:
-- 1. 删掉 lua/QQdock/
-- 2. plugs.lua 追加 require('plugs.QQdock')
-- 3. keymap.lua 不用改require('QQdock') 自动找到 lazy 安装的版本)
return {
{
'newbie/QQdock.nvim',
url = 'https://git.qyhhh.top/newbie/QQdock.nvim.git',
dependencies = { 'akinsho/toggleterm.nvim' },
config = function()
local Q = require('QQdock')
pcall(Q.setup, Q, {
size = {
horizontal = 10,
vertical = 40,
},
})
G.map({
{ 'n', '<c-t>', Q.shell, { noremap = true } },
{ 'i', '<c-t>', Q.shell, { noremap = true } },
{ 'n', '<C-i>', function() Q.open('reasonix') end, { noremap = true } },
{ 'n', '<leader>gg', function() Q.open('lazygit') end, { noremap = true } },
})
end,
},
}

View File

@ -8,43 +8,42 @@ return {
-- }) -- })
-- end -- end
-- }, -- },
-- { {
-- -- go开发 -- go 开发:只对 go/gomod 文件加载build 时检测是否装了 Go无 Go 环境静默跳过)
-- "ray-x/go.nvim", "ray-x/go.nvim",
-- dependencies = { -- optional packages dependencies = {
-- "ray-x/guihua.lua", "ray-x/guihua.lua",
-- "neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
-- "nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
-- }, },
-- config = function() ft = { "go", 'gomod' },
-- require("go").setup() build = function()
-- end, if vim.fn.executable('go') == 1 then
-- -- event = { "CmdlineEnter" }, require("go.install").update_all_sync()
-- ft = { "go", 'gomod' }, end
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries end,
-- }, config = function()
require("go").setup()
end,
},
{ {
-- conda 环境 -- conda 环境
"kmontocam/nvim-conda", "kmontocam/nvim-conda",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
}, },
{ {
-- 终端 -- toggleterm被 addons/QQdock 使用的底层终端
'akinsho/toggleterm.nvim', 'akinsho/toggleterm.nvim',
version = "*", version = "*",
config = function() config = function()
require("toggleterm").setup { require("toggleterm").setup {
-- size can be a number or function which is passed the current terminal
size = 10, size = 10,
open_mapping = [[<c-t>]], hide_numbers = true,
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {}, shade_filetypes = {},
shade_terminals = true, shade_terminals = true,
shading_factor = 1, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light shading_factor = 1,
start_in_insert = true, start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
persist_size = true, persist_size = true,
direction = 'horizontal',
} }
end end
} }

View File

@ -13,7 +13,6 @@ return {
{ {
'terryma/vim-multiple-cursors', 'terryma/vim-multiple-cursors',
}, },
{
--格式整理 --格式整理
{ {
'junegunn/vim-easy-align', 'junegunn/vim-easy-align',
@ -24,45 +23,50 @@ return {
}) })
end end
}, },
}, -- 注释插件Neovim 0.12 内置 treesitter gc/gcc 注释切换,暂注释掉此插件测试
{ -- {
-- 注释插件 -- 'tpope/vim-commentary',
{ -- },
'tpope/vim-commentary',
}
},
{ {
-- Copilot 懒加载:只在插入模式需要(和 nvim-cmp 共用 Tab 键cmp 改用 C-n/C-p 避让)
'github/copilot.vim', -- github copilot 'github/copilot.vim', -- github copilot
event = "InsertEnter",
}, },
{ {
'windwp/nvim-autopairs', 'windwp/nvim-autopairs',
event = "InsertEnter", event = "InsertEnter",
opts = {}, -- this is equalent to setup({}) function
config = function() config = function()
require('nvim-autopairs').setup({ require('nvim-autopairs').setup({
disable_filetype = { "vim" }, disable_filetype = { "vim" },
}) })
end end
}, },
-- {
-- 'kevinhwang91/nvim-ufo',
-- dependencies = {
-- 'kevinhwang91/promise-async'
-- },
-- config = function ()
-- require("ufo").setup()
-- end
-- },
{ {
-- hop 'kevinhwang91/nvim-ufo',
dependencies = {
'kevinhwang91/promise-async'
},
config = function()
vim.opt.foldcolumn = '0'
vim.opt.foldlevel = 99
vim.opt.foldlevelstart = 99
vim.opt.foldenable = true
require("ufo").setup({
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end
})
end
},
{
-- hop 快速跳转:用 f/F/t/T 做行内单字符跳转,<c-f> 做双字符跳转
-- 注意:这会覆盖 Vim 原生的 f/F/t/T
"phaazon/hop.nvim", "phaazon/hop.nvim",
branch = "v2", branch = "v2",
keys = { keys = {
"f", "F", "t", "T", "f", "F", "t", "T",
"<c-f>" "<c-f>"
}, },
lazy = true,
config = function() config = function()
require("hop").setup { keys = 'asdfghjkl;' } require("hop").setup { keys = 'asdfghjkl;' }
local hop = require('hop') local hop = require('hop')

29
lua/plugs/mason.lua Normal file
View File

@ -0,0 +1,29 @@
return {
{
-- lsp 下载器
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
},
config = function()
require "mason".setup {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
}
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
-- "basedpyright", -- Python LSP 需手动装(有的机器不用 Python
"lua_ls",
"jsonls",
"yamlls",
}
})
end
},
}

152
lua/plugs/nvim-cmp.lua Normal file
View File

@ -0,0 +1,152 @@
return {
{
-- lsp补全
"hrsh7th/nvim-cmp",
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
{
'hrsh7th/vim-vsnip',
config = function()
G.g.vsnip_snippet_dir = G.fn.stdpath("config") .. "/snippets"
end
},
'hrsh7th/cmp-vsnip',
'onsails/lspkind-nvim',
},
config = function()
local has_words_before = function()
local cursor = G.api.nvim_win_get_cursor(0)
local line, col = cursor[1], cursor[2]
return col ~= 0 and G.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local cmp = require('cmp')
local cmp_opt = {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
-- 补全来源优先级LSP > 片段 > buffer > 路径
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
},
{ name = 'buffer' },
{ name = 'path' }
),
-- 插入模式映射C-n/C-p 选择CR 未选时换行(避免冲突 Copilot 的 Tab
mapping = cmp.mapping.preset.insert({
-- 回车:手动选择后确认,未选时 fallback 到换行
["<CR>"] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }),
c = function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback()
end
end,
}),
-- C-n选下一个补全项 / 展开 vsnip 占位 / 手动触发补全
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
}),
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
border = "rounded",
scrollbar = false,
},
documentation = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
border = "rounded",
scrollbar = false,
},
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50, })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
}
require('cmp').setup(cmp_opt)
-- 命令栏补全Tab 导航,回车时若有手动选择则确认,否则直接执行命令(不卡住)
require('cmp').setup.cmdline(':', {
mapping = {
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'c' }),
['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'c' }),
['<CR>'] = cmp.mapping({
c = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ select = false })
else
fallback() -- 没选的时候 fallback = 直接执行命令
end
end,
}),
},
sources = {
{ name = 'cmdline' },
{ name = 'path' },
}
})
-- 搜索栏补全
require('cmp').setup.cmdline('/', {
mapping = {
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'c' }),
['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'c' }),
['<CR>'] = cmp.mapping({
c = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ select = false })
else
fallback()
end
end,
}),
},
sources = {
{ name = 'buffer' },
}
})
end,
},
}

View File

@ -4,11 +4,11 @@ return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { dependencies = {
"folke/neodev.nvim", "folke/neodev.nvim",
"hrsh7th/cmp-nvim-lsp",
}, },
config = function() config = function()
require 'neodev'.setup {} require 'neodev'.setup {}
-- 定义需要启用的服务器列表及其对应的配置
local servers = { local servers = {
lua_ls = require('lsp.lua'), lua_ls = require('lsp.lua'),
clangd = require('lsp.c'), clangd = require('lsp.c'),
@ -19,333 +19,23 @@ return {
jsonls = require('lsp.json'), jsonls = require('lsp.json'),
} }
-- 使用 Neovim 0.11+ 的新 API 进行配置和启用 -- capabilities 在此处统一注入,各 lsp/*.lua 不单独 require cmp_nvim_lsp
-- 避免模块层面 require 带来的隐式依赖
local capabilities = require('cmp_nvim_lsp').default_capabilities()
for server, config in pairs(servers) do for server, config in pairs(servers) do
config.capabilities = capabilities
vim.lsp.config(server, config) vim.lsp.config(server, config)
vim.lsp.enable(server) vim.lsp.enable(server)
end end
-- require 'lspconfig'.lua_ls.setup(require('lsp.lua'))
-- require 'lspconfig'.clangd.setup(require('lsp.c'))
-- require 'lspconfig'.bashls.setup(require('lsp.bash'))
-- require 'lspconfig'.basedpyright.setup(require('lsp.basedpyright'))
-- require 'lspconfig'.yamlls.setup(require('lsp.yaml'))
-- require 'lspconfig'.gopls.setup(require('lsp.go'))
-- require 'lspconfig'.jsonls.setup(require('lsp.json'))
G.map({ G.map({
{ 'n', '<cs-r>', '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>' }, { 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>' },
{ 'n', 'gh', '<cmd>lua vim.lsp.buf.hover()<CR>' }, { 'n', 'gh', '<cmd>lua vim.lsp.buf.hover()<CR>' },
{ 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>' }, { 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>' },
{ 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>' }, { 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>' },
{ 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>' }, { 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>' },
{ 'n', '<cs-i>', '<cmd>lua vim.lsp.buf.format()<CR>' }, { 'n', '<cs-i>', '<cmd>lua vim.lsp.buf.format()<CR>' },
})
end
},
{
-- lsp
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim", -- lsp 下载器
},
config = function()
require "mason".setup {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
}
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
-- "basedpyright",
"lua_ls",
"jsonls",
"yamlls",
}
})
end
},
{ --
'simrat39/symbols-outline.nvim',
config = function()
local opts = {
highlight_hovered_item = true,
show_guides = true,
auto_preview = false,
position = 'right',
relative_width = true,
width = 25,
auto_close = false,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = 'Pmenu',
autofold_depth = nil,
auto_unfold_hover = true,
fold_markers = { '', '' },
wrap = false,
keymaps = { -- These keymaps can be a string or a table for multiple keys
close = { "<Esc>", "q" },
goto_location = "<Cr>",
focus_location = "h",
hover_symbol = "<C-space>",
toggle_preview = "K",
rename_symbol = "r",
code_actions = "a",
fold = "o",
unfold = "l",
fold_all = "W",
unfold_all = "E",
fold_reset = "R",
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = { icon = "", hl = "@text.uri" },
Module = { icon = "", hl = "@namespace" },
Namespace = { icon = "", hl = "@namespace" },
Package = { icon = "", hl = "@namespace" },
Class = { icon = "𝓒", hl = "@type" },
Method = { icon = "ƒ", hl = "@method" },
Property = { icon = "", hl = "@method" },
Field = { icon = "", hl = "@field" },
Constructor = { icon = "", hl = "@constructor" },
Enum = { icon = "", hl = "@type" },
Interface = { icon = "", hl = "@type" },
Function = { icon = "", hl = "@function" },
Variable = { icon = "", hl = "@constant" },
Constant = { icon = "", hl = "@constant" },
String = { icon = "𝓐", hl = "@string" },
Number = { icon = "#", hl = "@number" },
Boolean = { icon = "", hl = "@boolean" },
Array = { icon = "", hl = "@constant" },
Object = { icon = "⦿", hl = "@type" },
Key = { icon = "🔐", hl = "@type" },
Null = { icon = "NULL", hl = "@type" },
EnumMember = { icon = "", hl = "@field" },
Struct = { icon = "𝓢", hl = "@type" },
Event = { icon = "🗲", hl = "@type" },
Operator = { icon = "+", hl = "@operator" },
TypeParameter = { icon = "𝙏", hl = "@parameter" },
Component = { icon = "", hl = "@function" },
Fragment = { icon = "", hl = "@constant" },
},
}
require("symbols-outline").setup(opts)
G.map({
{ "n", "<cs-o>", "<cmd>SymbolsOutline<cr>", { noremap = true } },
})
end
},
{
-- lsp补全
{
"hrsh7th/nvim-cmp",
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
'hrsh7th/cmp-path', -- { name = 'path' }
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
{
'hrsh7th/vim-vsnip',
config = function()
G.g.vsnip_snippet_dir = G.fn.stdpath("config") .. "/snippets"
end
},
'hrsh7th/cmp-vsnip',
'onsails/lspkind-nvim',
},
config = function()
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(G.api.nvim_win_get_cursor(0))
return col ~= 0 and G.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local cmp = require('cmp')
local cmp_opt = {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
},
{ name = 'buffer' },
{ name = 'path' }
),
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
c = function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
else
fallback()
end
end,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
}),
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
border = "rounded",
scrollbar = false,
},
documentation = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
border = "rounded",
scrollbar = false,
},
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50, })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
}
require('cmp').setup(cmp_opt)
end,
},
{
-- 语法高亮 --
'nvim-treesitter/nvim-treesitter',
config = function()
local treesitter_opt = {
ensure_installed = {
-- "c",
-- "cpp",
-- "python",
-- "java",
-- "lua",
-- "bash",
-- "vimdoc",
},
indent = { enable = true },
ignore_install = {
"txt",
"go"
},
sync_install = false,
auto_install = true,
highlight = {
enable = true,
disable = function(_, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = false,
},
parsers = {
html = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = { "src/parser.c" },
branch = "main"
}
}
}
}
require 'nvim-treesitter'.setup(treesitter_opt)
require 'nvim-treesitter.install'.prefer_git = true
if G.use_ssh then
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github/com/", "git@github.com:")
end
end
end
},
},
{
'fgheng/winbar.nvim',
config = function()
require('winbar').setup({
enabled = true, -- 是否启动winbar
-- show_file_path = true, -- 是否显示文件路径
show_symbols = true, -- 是否显示函数标签
-- 颜色配置,为空,将使用默认配色
colors = {
path = '#aaffff', -- 路径的颜色,比如#ababab
file_name = '#bbbbff', -- 文件名称的颜色,比如#acacac
symbols = '#aaffaa', -- 函数颜色
},
-- 图标配置
icons = {
seperator = '>', -- 路径分割符号
editor_state = '',
lock_icon = '',
},
-- 关闭winbar的窗口
exclude_filetype = {
'help',
'startify',
'dashboard',
'packer',
'neogitstatus',
'NvimTree',
'Trouble',
'alpha',
'lir',
'Outline',
'spectre_panel',
'toggleterm',
'qf',
}
}) })
end end
}, },

View File

@ -1,10 +1,10 @@
return { return {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
dependencies = { dependencies = {
'kyazdani42/nvim-web-devicons' 'nvim-tree/nvim-web-devicons'
}, },
keys = { keys = {
"<c-e>" { "<c-e>", "<cmd>NvimTreeToggle<CR>", desc = "Toggle file tree" }
}, },
config = function() config = function()
require 'nvim-web-devicons'.setup {} require 'nvim-web-devicons'.setup {}
@ -33,8 +33,5 @@ return {
}) })
end end
} }
G.map({
{ "n", "<C-e>", ":NvimTreeToggle<CR>", { noremap = true } },
})
end end
} }

View File

@ -0,0 +1,74 @@
return {
{ --
'simrat39/symbols-outline.nvim',
config = function()
local opts = {
highlight_hovered_item = true,
show_guides = true,
auto_preview = false,
position = 'right',
relative_width = true,
width = 25,
auto_close = false,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = 'Pmenu',
autofold_depth = nil,
auto_unfold_hover = true,
fold_markers = { '', '' },
wrap = false,
keymaps = {
close = { "<Esc>", "q" },
goto_location = "<CR>",
focus_location = "h",
hover_symbol = "<C-space>",
toggle_preview = "K",
rename_symbol = "r",
code_actions = "a",
fold = "o",
unfold = "l",
fold_all = "W",
unfold_all = "E",
fold_reset = "R",
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = { icon = "", hl = "@text.uri" },
Module = { icon = "", hl = "@namespace" },
Namespace = { icon = "", hl = "@namespace" },
Package = { icon = "", hl = "@namespace" },
Class = { icon = "𝓒", hl = "@type" },
Method = { icon = "ƒ", hl = "@method" },
Property = { icon = "", hl = "@method" },
Field = { icon = "", hl = "@field" },
Constructor = { icon = "", hl = "@constructor" },
Enum = { icon = "", hl = "@type" },
Interface = { icon = "", hl = "@type" },
Function = { icon = "", hl = "@function" },
Variable = { icon = "", hl = "@constant" },
Constant = { icon = "", hl = "@constant" },
String = { icon = "𝓐", hl = "@string" },
Number = { icon = "#", hl = "@number" },
Boolean = { icon = "", hl = "@boolean" },
Array = { icon = "", hl = "@constant" },
Object = { icon = "⦿", hl = "@type" },
Key = { icon = "🔐", hl = "@type" },
Null = { icon = "NULL", hl = "@type" },
EnumMember = { icon = "", hl = "@field" },
Struct = { icon = "𝓢", hl = "@type" },
Event = { icon = "🗲", hl = "@type" },
Operator = { icon = "+", hl = "@operator" },
TypeParameter = { icon = "𝙏", hl = "@parameter" },
Component = { icon = "", hl = "@function" },
Fragment = { icon = "", hl = "@constant" },
},
}
require("symbols-outline").setup(opts)
G.map({
{ "n", "<cs-o>", "<cmd>SymbolsOutline<cr>", { noremap = true } },
})
end
},
}

View File

@ -7,8 +7,7 @@ return {
end end
}, },
{ {
-- line插件 -- 状态栏
'kdheepak/tabline.nvim',
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
config = function() config = function()
require('lualine').setup { require('lualine').setup {
@ -17,17 +16,13 @@ return {
theme = 'auto', theme = 'auto',
component_separators = { left = '', right = '' }, component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' }, section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {}, ignore_focus = {},
always_divide_middle = true, always_divide_middle = true,
globalstatus = false, globalstatus = false,
refresh = { refresh = {
statusline = 1000, statusline = 2000,
tabline = 1000, tabline = 2000,
winbar = 1000, winbar = 2000,
} }
}, },
sections = { sections = {
@ -50,33 +45,32 @@ return {
lualine_y = {}, lualine_y = {},
lualine_z = {} lualine_z = {}
}, },
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
} }
end,
},
{
-- 标签栏
'kdheepak/tabline.nvim',
config = function()
require('tabline').setup { require('tabline').setup {
-- Defaults configuration options
enable = true, enable = true,
options = { options = {
-- If lualine is installed tabline will use separators configured in lualine by default.
-- These options can be used to override those settings.
section_separators = { ' ', ' ' }, section_separators = { ' ', ' ' },
component_separators = { '', '' }, component_separators = { '', '' },
max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3 max_bufferline_percent = 66,
show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named show_tabs_always = false,
show_devicons = true, -- this shows devicons in buffer section show_devicons = true,
show_bufnr = false, -- this appends [bufnr] to buffer section, show_bufnr = false,
show_filename_only = true, -- shows base filename only instead of relative path in filename show_filename_only = true,
modified_icon = "+ ", -- change the default modified icon modified_icon = "+ ",
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified modified_italic = false,
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers show_tabs_only = false,
}, },
}
G.cmd [[ G.cmd [[
set guioptions-=e " Use showtabline in gui vim set guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session set sessionoptions+=tabpages,globals " store tabpages and globals in session
]] ]]
}
end, end,
}, },
} }

46
lua/plugs/treesitter.lua Normal file
View File

@ -0,0 +1,46 @@
return {
{
-- 语法高亮auto_install=true 自动装 parserignore_install 跳过 txt
'nvim-treesitter/nvim-treesitter',
config = function()
local treesitter_opt = {
indent = { enable = true },
ignore_install = {
"txt"
},
sync_install = false,
auto_install = true,
highlight = {
enable = true,
-- 大于 100KB 的文件关闭 treesitter 高亮(性能优化)
disable = function(_, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = false,
},
-- 自定义 Vue parser上游 tree-sitter-html 不识别 .vue 单文件组件
parsers = {
vue = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = { "src/parser.c" },
branch = "main",
},
},
},
}
require 'nvim-treesitter'.setup(treesitter_opt)
require 'nvim-treesitter.install'.prefer_git = true
if G.use_ssh then
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:")
end
end
end
},
}

40
lua/plugs/winbar.lua Normal file
View File

@ -0,0 +1,40 @@
return {
{
'fgheng/winbar.nvim',
config = function()
require('winbar').setup({
enabled = true,
show_symbols = true,
colors = {
path = '#aaffff',
file_name = '#bbbbff',
symbols = '#aaffaa',
},
icons = {
separator = '>',
editor_state = '',
lock_icon = '',
},
exclude_filetype = {
'help',
'startify',
'dashboard',
'packer',
'neogitstatus',
'NvimTree',
'Trouble',
'alpha',
'lir',
'Outline',
'spectre_panel',
'toggleterm',
'qf',
}
})
end
},
}

View File

@ -1,4 +1,3 @@
require 'lazy'.setup({ require 'lazy'.setup({
require('plugs.edit-plugs'), require('plugs.edit-plugs'),
-- 'vijaymarupudi/nvim-fzf', -- fzf
}) })

View File

@ -1,3 +1,91 @@
{ {
"plug": {
"prefix": "plug",
"body": [
"{",
" '${1:owner/repo}',",
" config = function()",
" require('${2}').setup({$3})",
" end,",
"},"
]
},
"plugkey": {
"prefix": "plugkey",
"body": [
"{",
" '${1:owner/repo}',",
" keys = { '${2}' },",
" config = function()",
" require('${3}').setup({$4})",
" end,",
"},"
]
},
"plugftp": {
"prefix": "plugftp",
"body": [
"{",
" '${1:owner/repo}',",
" ft = { '${2}' },",
" config = function()",
" require('${3}').setup({$4})",
" end,",
"},"
]
},
"map": {
"prefix": "map",
"body": "{ '${1:n}', '${2:<leader>}', '${3:cmd}', { noremap = true } },"
},
"mapl": {
"prefix": "mapl",
"body": [
"{ '${1:n}', '${2:<leader>}',",
" function()",
" ${3}",
" end,",
" { noremap = true }",
"},"
]
},
"func": {
"prefix": "func",
"body": [
"function ${1:name}(${2:args})",
" ${3}",
"end"
]
},
"localf": {
"prefix": "localf",
"body": [
"local ${1:name} = function(${2:args})",
" ${3}",
"end"
]
},
"Gmap": {
"prefix": "Gmap",
"body": [
"G.map({",
" { '${1:n}', '${2:<leader>}', '${3:cmd}', { noremap = true } },",
"})"
]
},
"req": {
"prefix": "req",
"body": "local ${1:name} = require('${1}')"
},
"au": {
"prefix": "au",
"body": [
"G.au({ '${1:BufEnter}' }, {",
" pattern = { '${2:*}' },",
" callback = function()",
" ${3}",
" end,",
"})"
]
}
} }