mirror of
https://github.com/d0zingcat/dotfiles.git
synced 2026-05-15 23:16:47 +00:00
feat: a lot of configs
Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
@@ -1,26 +1,116 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
--
|
||||
-- Add any additional autocmds here
|
||||
-- with `vim.api.nvim_create_autocmd`
|
||||
--
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
||||
-- autocmds.lua - 自动命令配置
|
||||
|
||||
vim.cmd('filetype plugin indent on')
|
||||
-- 创建自动命令组
|
||||
local augroup = vim.api.nvim_create_augroup("MyCustomGroup", { clear = true })
|
||||
|
||||
-- Create a group for our autocommands
|
||||
local augroup = vim.api.nvim_create_augroup("CustomSettings", { clear = true })
|
||||
-- 自动设置光标行
|
||||
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
if vim.bo.buftype ~= "terminal" then
|
||||
vim.opt_local.cursorline = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- FileType autocommands
|
||||
vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
if vim.bo.buftype ~= "terminal" then
|
||||
vim.opt_local.cursorline = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 高亮复制文本
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
|
||||
end,
|
||||
})
|
||||
|
||||
-- 自动切换工作目录
|
||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
desc = "自动切换到文件所在目录",
|
||||
callback = function()
|
||||
local buftype = vim.bo.buftype
|
||||
if buftype ~= "terminal" and buftype ~= "nofile" and buftype ~= "prompt" then
|
||||
vim.cmd("silent! lcd %:p:h")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 自动恢复光标位置
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
group = augroup,
|
||||
desc = "恢复光标位置",
|
||||
callback = function()
|
||||
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||
local lcount = vim.api.nvim_buf_line_count(0)
|
||||
if mark[1] > 0 and mark[1] <= lcount then
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 自动关闭某些窗口的 q 键
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"qf",
|
||||
"help",
|
||||
"man",
|
||||
"notify",
|
||||
"lspinfo",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
"spectre_panel",
|
||||
"PlenaryTestPopup",
|
||||
},
|
||||
group = augroup,
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- 在保存时自动删除行尾空白字符
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
desc = "删除行尾空白字符",
|
||||
callback = function()
|
||||
-- 保存当前位置
|
||||
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
||||
-- 保存搜索寄存器
|
||||
local search = vim.fn.getreg("/")
|
||||
|
||||
-- 替换所有行尾空白字符
|
||||
vim.cmd([[%s/\s\+$//e]])
|
||||
|
||||
-- 恢复搜索寄存器
|
||||
vim.fn.setreg("/", search)
|
||||
-- 恢复光标位置
|
||||
vim.api.nvim_win_set_cursor(0, cursor_pos)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 自动设置文件类型的选项
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "python",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 4
|
||||
vim.opt_local.expandtab = true
|
||||
vim.opt_local.shiftwidth = 4
|
||||
vim.opt_local.tabstop = 4
|
||||
vim.opt_local.softtabstop = 4
|
||||
vim.opt_local.textwidth = 120
|
||||
vim.opt_local.textwidth = 88 -- 符合 black 格式化
|
||||
vim.opt_local.colorcolumn = "88"
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -28,112 +118,20 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "go",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 4
|
||||
vim.opt_local.shiftwidth = 4
|
||||
vim.opt_local.softtabstop = 4
|
||||
vim.opt_local.textwidth = 120
|
||||
vim.opt_local.expandtab = false
|
||||
vim.opt_local.shiftwidth = 4
|
||||
vim.opt_local.tabstop = 4
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "json", "jsonnet" },
|
||||
pattern = { "javascript", "typescript", "javascriptreact", "typescriptreact", "json", "html", "css", "yaml", "markdown" },
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "yaml",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 0
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "gotmpl",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 0
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "php",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 120
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "html", "htmldjango", "xhtml", "haml" },
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 0
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "ruby",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 120
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "less", "sass", "scss", "css" },
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 120
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "javascript", "javascript.jsx", "javascriptreact", "typescript", "typescriptreact" },
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "NvimTree",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.textwidth = 0
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -142,23 +140,73 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = false
|
||||
vim.opt_local.shiftwidth = 8
|
||||
vim.opt_local.softtabstop = 0
|
||||
end,
|
||||
})
|
||||
|
||||
-- File pattern autocommands
|
||||
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
|
||||
pattern = "*.proto",
|
||||
group = augroup,
|
||||
command = "setfiletype proto",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "proto",
|
||||
-- 为新文件创建模板
|
||||
vim.api.nvim_create_autocmd("BufNewFile", {
|
||||
pattern = "*.py",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.expandtab = true
|
||||
local lines = {
|
||||
"#!/usr/bin/env python3",
|
||||
"# -*- coding: utf-8 -*-",
|
||||
"\"\"\"",
|
||||
"Description: ",
|
||||
"\"\"\"",
|
||||
"",
|
||||
"",
|
||||
"def main():",
|
||||
" pass",
|
||||
"",
|
||||
"",
|
||||
"if __name__ == \"__main__\":",
|
||||
" main()",
|
||||
"",
|
||||
}
|
||||
vim.api.nvim_buf_set_lines(0, 0, 0, false, lines)
|
||||
vim.api.nvim_win_set_cursor(0, { 4, 13 })
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufNewFile", {
|
||||
pattern = "*.go",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
local package_name = vim.fn.fnamemodify(vim.fn.expand("%:p:h:t"), ":r")
|
||||
|
||||
local lines = {
|
||||
"package " .. package_name,
|
||||
"",
|
||||
"import (",
|
||||
"\t\"fmt\"",
|
||||
")",
|
||||
"",
|
||||
"// TODO: Add description here",
|
||||
"",
|
||||
"",
|
||||
}
|
||||
vim.api.nvim_buf_set_lines(0, 0, 0, false, lines)
|
||||
vim.api.nvim_win_set_cursor(0, { 7, 27 })
|
||||
end,
|
||||
})
|
||||
|
||||
-- 在外部更改时自动重新加载文件
|
||||
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
if vim.fn.mode() ~= "c" and not vim.bo.readonly then
|
||||
vim.cmd("checktime")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 当 checktime 检测到文件已更改时通知
|
||||
vim.api.nvim_create_autocmd("FileChangedShellPost", {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN)
|
||||
end,
|
||||
})
|
||||
@@ -1,3 +1,117 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
-- Add any additional keymaps here
|
||||
-- keymaps.lua - 键位映射配置
|
||||
|
||||
-- 设置局部变量
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
--[[
|
||||
模式说明:
|
||||
n: 普通模式
|
||||
i: 插入模式
|
||||
v: 可视模式
|
||||
x: 可视块模式
|
||||
t: 终端模式
|
||||
c: 命令行模式
|
||||
]]--
|
||||
|
||||
-----------------
|
||||
-- 基础键位映射 --
|
||||
-----------------
|
||||
|
||||
-- 使用 jk 从插入模式返回普通模式
|
||||
map("i", "jk", "<ESC>", opts)
|
||||
|
||||
-- 保存和退出
|
||||
map("n", "<leader>w", "<cmd>w<cr>", { desc = "保存文件" })
|
||||
map("n", "<leader>q", "<cmd>q<cr>", { desc = "退出" })
|
||||
map("n", "<leader>Q", "<cmd>qa<cr>", { desc = "退出全部" })
|
||||
|
||||
-- 清除搜索高亮
|
||||
map("n", "<leader>h", "<cmd>nohlsearch<cr>", { desc = "清除搜索高亮" })
|
||||
|
||||
-- 更好的缩进
|
||||
map("v", "<", "<gv", opts)
|
||||
map("v", ">", ">gv", opts)
|
||||
|
||||
-- 上下移动选中的文本
|
||||
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "向下移动选中文本" })
|
||||
map("v", "K", ":m '<-2<CR>gv=gv", { desc = "向上移动选中文本" })
|
||||
|
||||
-- 保持复制内容在粘贴后
|
||||
map("x", "p", [["_dP]], { desc = "粘贴不覆盖寄存器" })
|
||||
|
||||
-- 删除到黑洞寄存器
|
||||
map({ "n", "v" }, "<leader>d", [["_d]], { desc = "删除到黑洞寄存器" })
|
||||
|
||||
-- 快速移动
|
||||
map("n", "J", "mzJ`z", { desc = "连接行保持光标位置" })
|
||||
map("n", "<C-d>", "<C-d>zz", { desc = "向下移动保持光标居中" })
|
||||
map("n", "<C-u>", "<C-u>zz", { desc = "向上移动保持光标居中" })
|
||||
map("n", "n", "nzzzv", { desc = "下一个搜索结果并居中" })
|
||||
map("n", "N", "Nzzzv", { desc = "上一个搜索结果并居中" })
|
||||
|
||||
-------------------------
|
||||
-- 窗口和缓冲区管理 --
|
||||
-------------------------
|
||||
|
||||
-- 窗口间导航
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "移动到左窗口" })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "移动到下窗口" })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "移动到上窗口" })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "移动到右窗口" })
|
||||
|
||||
-- 缓冲区导航
|
||||
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "上一个缓冲区" })
|
||||
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "下一个缓冲区" })
|
||||
map("n", "<leader>bd", "<cmd>bdelete<cr>", { desc = "关闭当前缓冲区" })
|
||||
map("n", "<leader>ba", "<cmd>bufdo bd<cr>", { desc = "关闭所有缓冲区" })
|
||||
|
||||
-- 窗口分割
|
||||
map("n", "<leader>sv", "<cmd>vsplit<cr>", { desc = "垂直分割" })
|
||||
map("n", "<leader>sh", "<cmd>split<cr>", { desc = "水平分割" })
|
||||
map("n", "<leader>se", "<C-w>=", { desc = "使所有窗口等宽" })
|
||||
map("n", "<leader>sx", "<cmd>close<cr>", { desc = "关闭当前窗口" })
|
||||
|
||||
-- 调整窗口大小
|
||||
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "增加窗口高度" })
|
||||
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "减小窗口高度" })
|
||||
map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "减小窗口宽度" })
|
||||
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "增加窗口宽度" })
|
||||
|
||||
-------------------------
|
||||
-- 终端模式映射 --
|
||||
-------------------------
|
||||
|
||||
-- 退出终端模式
|
||||
map("t", "<Esc>", "<C-\\><C-n>", { desc = "退出终端模式" })
|
||||
map("t", "jk", "<C-\\><C-n>", { desc = "退出终端模式" })
|
||||
|
||||
-- 终端窗口导航
|
||||
map("t", "<C-h>", "<C-\\><C-n><C-w>h", { desc = "终端模式下向左移动" })
|
||||
map("t", "<C-j>", "<C-\\><C-n><C-w>j", { desc = "终端模式下向下移动" })
|
||||
map("t", "<C-k>", "<C-\\><C-n><C-w>k", { desc = "终端模式下向上移动" })
|
||||
map("t", "<C-l>", "<C-\\><C-n><C-w>l", { desc = "终端模式下向右移动" })
|
||||
|
||||
-------------------------
|
||||
-- 实用功能 --
|
||||
-------------------------
|
||||
|
||||
-- 全文快速替换当前单词
|
||||
map("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = "替换当前单词" })
|
||||
|
||||
-- 使当前文件可执行
|
||||
map("n", "<leader>x", "<cmd>!chmod +x %<CR>", { desc = "使当前文件可执行", silent = true })
|
||||
|
||||
-- 打开一个新的终端
|
||||
map("n", "<leader>t", "<cmd>terminal<cr>", { desc = "打开终端" })
|
||||
|
||||
-- 快速编辑配置文件
|
||||
map("n", "<leader>ev", "<cmd>e $MYVIMRC<cr>", { desc = "编辑init.lua" })
|
||||
map("n", "<leader>sv", "<cmd>source $MYVIMRC<cr>", { desc = "重新加载配置" })
|
||||
|
||||
-- 更简单的命令行历史导航
|
||||
map("c", "<C-j>", "<Down>", { desc = "下一个命令历史" })
|
||||
map("c", "<C-k>", "<Up>", { desc = "上一个命令历史" })
|
||||
|
||||
-- 更好的搜索
|
||||
map("n", "g/", "/\\<\\><Left><Left>", { desc = "搜索单词" })
|
||||
@@ -1,3 +1,6 @@
|
||||
-- lazy.lua - lazy.nvim 插件管理器配置
|
||||
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
@@ -14,40 +17,75 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- 配置 lazy.nvim
|
||||
require("lazy").setup({
|
||||
-- 插件列表
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- import/override with your plugins
|
||||
-- 导入插件模块
|
||||
{ import = "plugins" },
|
||||
},
|
||||
|
||||
-- 默认配置
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
lazy = false, -- 默认不延迟加载
|
||||
version = false, -- 使用最新版本
|
||||
},
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = {
|
||||
enabled = true, -- check for plugin updates periodically
|
||||
notify = false, -- notify on update
|
||||
}, -- automatically check for plugin updates
|
||||
|
||||
-- 安装配置
|
||||
install = {
|
||||
colorscheme = { "tokyonight", "habamax" }, -- 安装时使用的主题
|
||||
missing = true, -- 自动安装缺失的插件
|
||||
},
|
||||
|
||||
-- 性能配置
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
-- 禁用一些内置插件
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
"gzip", -- 不需要在编辑器内处理 gzip 文件
|
||||
"matchit", -- 使用 treesitter 代替
|
||||
"matchparen", -- 使用 treesitter 代替
|
||||
"netrwPlugin", -- 使用 nvim-tree 代替
|
||||
"tarPlugin", -- 不需要在编辑器内处理 tar 文件
|
||||
"tohtml", -- 不需要转换为 HTML
|
||||
"tutor", -- 不需要内置教程
|
||||
"zipPlugin", -- 不需要在编辑器内处理 zip 文件
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- UI 配置
|
||||
ui = {
|
||||
-- 自定义图标
|
||||
icons = {
|
||||
cmd = "⌘",
|
||||
config = "🛠",
|
||||
event = "📅",
|
||||
ft = "📂",
|
||||
init = "⚙",
|
||||
keys = "🔑",
|
||||
plugin = "🔌",
|
||||
runtime = "💻",
|
||||
source = "📄",
|
||||
start = "🚀",
|
||||
task = "📌",
|
||||
lazy = "💤 ",
|
||||
},
|
||||
size = { width = 0.8, height = 0.8 }, -- 窗口大小
|
||||
wrap = true, -- 自动换行
|
||||
border = "rounded", -- 边框样式
|
||||
},
|
||||
|
||||
-- 检查更新配置
|
||||
checker = {
|
||||
enabled = true, -- 启用自动检查更新
|
||||
frequency = 3600, -- 检查频率(秒)
|
||||
notify = false, -- 禁用更新通知
|
||||
},
|
||||
|
||||
-- 更新配置
|
||||
change_detection = {
|
||||
enabled = true, -- 启用自动重载
|
||||
notify = false, -- 禁用更改通知
|
||||
},
|
||||
})
|
||||
@@ -1,55 +1,89 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
-- options.lua - 基本编辑器选项设置
|
||||
|
||||
local opt = vim.opt
|
||||
local o = vim.o
|
||||
local g = vim.g
|
||||
|
||||
g.loaded_netrw = 1
|
||||
g.loaded_netrwPlugin = 1
|
||||
o.termguicolors = true
|
||||
-- UI设置
|
||||
opt.termguicolors = true -- 使用终端真彩色
|
||||
opt.number = true -- 显示行号
|
||||
opt.relativenumber = true -- 相对行号
|
||||
opt.cursorline = true -- 高亮当前行
|
||||
opt.cursorcolumn = true -- 高亮当前列
|
||||
opt.signcolumn = "auto:1" -- 显示标记列
|
||||
opt.showmatch = true -- 高亮匹配的括号
|
||||
opt.showmode = false -- 不显示模式,由状态栏插件替代
|
||||
opt.laststatus = 3 -- 全局状态栏
|
||||
opt.cmdheight = 1 -- 命令行高度
|
||||
opt.scrolloff = 10 -- 光标上下保留的行数
|
||||
opt.sidescrolloff = 10 -- 光标左右保留的列数
|
||||
opt.wrap = false -- 不自动换行
|
||||
opt.linebreak = true -- 如果wrap开启,在单词边界处换行
|
||||
opt.list = true -- 显示不可见字符
|
||||
opt.listchars = { -- 设置不可见字符的显示方式
|
||||
tab = "» ",
|
||||
trail = "·",
|
||||
extends = "›",
|
||||
precedes = "‹",
|
||||
nbsp = "␣",
|
||||
eol = "↴"
|
||||
}
|
||||
opt.fillchars:append({ -- 分隔符符号设置
|
||||
vert = "│", -- 窗口分隔符
|
||||
fold = "⠀", -- 折叠
|
||||
eob = " ", -- 缓冲区末尾的空行
|
||||
diff = "╱", -- 差异模式的删除行
|
||||
})
|
||||
|
||||
g.mapleader = ' ' -- Make sure to set `mapleader` before lazy so your mappings are correct
|
||||
g.maplocalleader = '\\' -- Same for `maplocalleader`
|
||||
-- 编辑设置
|
||||
opt.tabstop = 4 -- Tab宽度
|
||||
opt.softtabstop = 4 -- 编辑时的Tab宽度
|
||||
opt.shiftwidth = 4 -- 缩进宽度
|
||||
opt.expandtab = true -- 使用空格替代Tab
|
||||
opt.smartindent = true -- 智能缩进
|
||||
opt.autoindent = true -- 自动缩进
|
||||
opt.cindent = true -- C语言缩进规则
|
||||
opt.textwidth = 120 -- 文本宽度
|
||||
opt.formatoptions = "jcroqlnt" -- 格式化选项
|
||||
opt.foldenable = false -- 默认不折叠
|
||||
opt.foldmethod = "expr" -- 使用表达式进行折叠
|
||||
opt.foldexpr = "nvim_treesitter#foldexpr()" -- 使用treesitter进行折叠
|
||||
|
||||
o.encoding = 'utf-8'
|
||||
o.fileencoding = 'utf-8'
|
||||
o.fencs = 'utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936'
|
||||
o.hidden = true
|
||||
o.wildmenu = true
|
||||
o.hlsearch = true
|
||||
o.incsearch = true
|
||||
o.matchtime = 1
|
||||
o.showmatch = true
|
||||
o.updatetime = 100
|
||||
o.ignorecase = true
|
||||
o.smarttab = true
|
||||
o.expandtab = true
|
||||
o.laststatus = 2
|
||||
o.showcmd = true
|
||||
o.ruler = true
|
||||
o.history = 300
|
||||
o.backup = false
|
||||
o.swapfile = false
|
||||
o.foldenable = false
|
||||
o.autoread = true
|
||||
o.autowrite = true
|
||||
o.mouse = 'a'
|
||||
-- 搜索设置
|
||||
opt.ignorecase = true -- 搜索忽略大小写
|
||||
opt.smartcase = true -- 如果搜索包含大写字母,则区分大小写
|
||||
opt.hlsearch = true -- 高亮搜索结果
|
||||
opt.incsearch = true -- 增量搜索
|
||||
|
||||
o.number = true
|
||||
o.cursorline = true
|
||||
o.relativenumber = true
|
||||
o.cursorcolumn = true
|
||||
o.signcolumn = 'auto:1'
|
||||
-- o.cmdheight = 0
|
||||
opt.list = true
|
||||
opt.listchars:append('eol:↴')
|
||||
opt.fillchars:append { diff = '╱' }
|
||||
-- 性能设置
|
||||
opt.hidden = true -- 允许切换未保存的缓冲区
|
||||
opt.history = 500 -- 历史记录数
|
||||
opt.updatetime = 100 -- 更新时间(ms)
|
||||
opt.timeout = true -- 启用超时
|
||||
opt.timeoutlen = 300 -- 键映射超时时间(ms)
|
||||
opt.ttimeoutlen = 10 -- 键码超时时间(ms)
|
||||
opt.synmaxcol = 240 -- 最大语法分析列数
|
||||
|
||||
o.textwidth = 120
|
||||
o.smartindent = true
|
||||
o.autoindent = true
|
||||
o.cindent = true
|
||||
o.shiftwidth = 4
|
||||
o.softtabstop = 4
|
||||
o.tabstop = 4
|
||||
-- 文件设置
|
||||
opt.fileencoding = "utf-8" -- 文件编码
|
||||
opt.backup = false -- 不创建备份文件
|
||||
opt.swapfile = false -- 不创建交换文件
|
||||
opt.undofile = true -- 启用持久撤销
|
||||
opt.undodir = vim.fn.stdpath("data") .. "/undo" -- 撤销文件目录
|
||||
|
||||
-- 鼠标设置
|
||||
opt.mouse = "a" -- 启用鼠标
|
||||
|
||||
-- 分隔符设置
|
||||
opt.splitbelow = true -- 新的水平分割窗口在下面
|
||||
opt.splitright = true -- 新的垂直分割窗口在右边
|
||||
|
||||
-- 通用设置
|
||||
opt.clipboard = "unnamedplus" -- 使用系统剪贴板
|
||||
opt.completeopt = "menu,menuone,noselect" -- 补全选项
|
||||
opt.pumheight = 10 -- 弹出菜单高度
|
||||
opt.confirm = true -- 显示确认对话框
|
||||
opt.autoread = true -- 自动重新加载文件
|
||||
|
||||
-- 加载 .nvimrc, .exrc 等本地配置
|
||||
opt.exrc = true -- 启用 .exrc
|
||||
opt.secure = true -- 限制本地配置中的命令
|
||||
Reference in New Issue
Block a user