mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 16:51:33 +00:00
disable useless autocmd
This commit is contained in:
@ -73,30 +73,30 @@ local function matches_gitignore(file_path, rules)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
-- 自动更新磁盘上更改的文件,可跳过某些目录
|
-- 自动更新磁盘上更改的文件,可跳过某些目录
|
||||||
local skip_dirs = { "" } -- 手动指定要跳过检测的目录列表
|
-- local skip_dirs = { "" } -- 手动指定要跳过检测的目录列表
|
||||||
local gitignore_rules = parse_gitignore()
|
-- local gitignore_rules = parse_gitignore()
|
||||||
autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
|
-- autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
|
||||||
callback = function()
|
-- callback = function()
|
||||||
if vim.fn.mode() == "c" or vim.fn.bufexists("[Command Line]") then
|
-- if vim.fn.mode() == "c" or vim.fn.bufexists("[Command Line]") then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
local bufname = vim.api.nvim_buf_get_name(0)
|
-- local bufname = vim.api.nvim_buf_get_name(0)
|
||||||
for _, dir in ipairs(skip_dirs) do
|
-- for _, dir in ipairs(skip_dirs) do
|
||||||
if string.find(bufname, dir, 1, true) then
|
-- if string.find(bufname, dir, 1, true) then
|
||||||
return -- 如果文件在手动跳过的目录中,不进行检测
|
-- return -- 如果文件在手动跳过的目录中,不进行检测
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
if matches_gitignore(bufname, gitignore_rules) then
|
-- if matches_gitignore(bufname, gitignore_rules) then
|
||||||
return -- 如果文件匹配 .gitignore 规则,不进行检测
|
-- return -- 如果文件匹配 .gitignore 规则,不进行检测
|
||||||
end
|
-- end
|
||||||
vim.cmd("checktime")
|
-- vim.cmd("checktime")
|
||||||
end,
|
-- end,
|
||||||
})
|
-- })
|
||||||
|
--
|
||||||
-- 文件更改后的通知
|
-- 文件更改后的通知
|
||||||
autocmd("FileChangedShellPost", {
|
-- autocmd("FileChangedShellPost", {
|
||||||
command = [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]],
|
-- command = [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]],
|
||||||
})
|
-- })
|
||||||
|
|
||||||
-- 用 o 换行不要延续注释
|
-- 用 o 换行不要延续注释
|
||||||
local myAutoGroup = vim.api.nvim_create_augroup("myAutoGroup", {
|
local myAutoGroup = vim.api.nvim_create_augroup("myAutoGroup", {
|
||||||
@ -222,8 +222,3 @@ autocmd({ "BufReadPre" }, {
|
|||||||
group = aug,
|
group = aug,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- 在 Vim 退出前保存会话
|
|
||||||
-- autocmd("VimLeavePre", {
|
|
||||||
-- command = ":SessionSave",
|
|
||||||
-- })
|
|
||||||
|
Reference in New Issue
Block a user