Files
nvim/lua/config/autocmds.lua
2025-05-09 22:16:19 +08:00

36 lines
1.1 KiB
Lua

local function augroup(name)
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
end
vim.api.nvim_create_autocmd("FileType", {
group = augroup("wrap_spell"),
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
-- vim.opt_local.spell = false -- 覆盖默认的 true
end,
})
vim.api.nvim_create_autocmd("FileType", {
group = augroup("associate_filetype"),
pattern = { "cpp","php","go","jsx","js","html","css","c", "rust", "python","lua" },
callback = function()
-- vim.opt.shiftwidth = 2
-- 防止使用 o 切换到下一行的时候自动加上注释符号(在上一行是注释的情况下)
vim.opt.formatoptions:remove({ "o" })
end,
})
vim.api.nvim_create_autocmd("FileType", {
group = augroup("associate_filetype"),
pattern = { "cpp","php","go","jsx","js","html","css","c", "rust", "python","lua" },
callback = function()
vim.opt.shiftwidth = 4
-- 防止使用 o 切换到下一行的时候自动加上注释符号(在上一行是注释的情况下)
vim.opt.formatoptions:remove({ "o" })
end,
})