nvim1/lua/configs/autocmds.lua

42 lines
894 B
Lua

local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd
autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank({
higroup = "IncSearch",
timeout = 1000,
})
end,
})
-- Remove whitespace on save.
autocmd("BufWritePre", {
pattern = "",
command = ":%s/\\s\\+$//e",
})
-- Do not auto comment new line.
autocmd("BufEnter", {
pattern = "",
command = "set fo-=c fo-=r fo-=o",
})
autocmd("Filetype", {
pattern = { "xml", "html", "xhtml", "css", "scss", "javascript", "typescript", "yaml", "sshconfig" },
command = "setlocal shiftwidth=2 tabstop=2",
})
autocmd("Filetype", {
pattern = { "python", "rst", "rs", "c", "cpp", "go", "java" },
command = "set colorcolumn=80",
})
autocmd("Filetype", {
pattern = { "gitcommit", "markdown", "text" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})