refactor: 重构Neovim配置结构并更新文档

- 调整配置文件组织方式,新增init.lua作为入口
- 更新lazy-lock.json同步插件版本
- 完善lua/目录下的插件和配置模块结构
- 修改README.md补充配置说明和使用指南
This commit is contained in:
2025-12-15 09:57:50 +08:00
parent 937cff0da3
commit 11565f3c55
26 changed files with 1225 additions and 1 deletions

75
lua/config/basic.lua Normal file
View File

@@ -0,0 +1,75 @@
-- ===== 基本设置 =====
-- 行号
vim.opt.number = true
vim.opt.relativenumber = true
-- 缩进
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
-- 搜索
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
-- 外观
vim.opt.termguicolors = true
vim.opt.background = "dark"
vim.opt.signcolumn = "yes"
vim.opt.cursorline = true
vim.opt.colorcolumn = "80" -- 在第80列显示参考线
-- 文件和备份
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undofile = false
-- 分割窗口
vim.opt.splitright = true
vim.opt.splitbelow = true
-- 其他
vim.opt.mouse = "a" -- 启用鼠标
vim.opt.updatetime = 50 -- 更快的响应时间
vim.opt.timeoutlen = 300 -- 快捷键响应时间
vim.opt.scrolloff = 8 -- 光标距离边界8行时滚动
vim.opt.wrap = false -- 不自动换行
vim.opt.errorbells = false -- 不发出错误声音
vim.opt.visualbell = false -- 不使用视觉提示
-- 领导键
vim.g.mapleader = " "
vim.g.localleader = "\\"
-- 剪切板
vim.g.clipboard = {
name = "wl-clipboard",
copy = {
["+"] = { "wl-copy" },
["*"] = { "wl-copy" },
},
paste = {
["+"] = { "wl-paste" },
["*"] = { "wl-paste" },
},
cache_enabled = 0,
}
vim.opt.clipboard = "unnamedplus"
vim.opt.shell = "zsh"
vim.api.nvim_create_user_command("Term", "terminal", { desc = "打开终端" })
vim.keymap.set("n", "<leader>t", "<cmd>Term<cr>", { desc = "打开终端" })
-- 终端模式快捷键
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "*",
callback = function()
vim.keymap.set("t", "<ESC>", "<C-\\><C-n>", { buffer = true, desc = "退出终端模式" })
vim.opt_local.number = false
vim.opt_local.relativenumber = false
end,
})

15
lua/config/lazy.lua Normal file
View File

@@ -0,0 +1,15 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "git@github.com:folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)