This commit is contained in:
Manuel
2025-08-25 17:42:37 +02:00
commit aed2435b50
31 changed files with 2269 additions and 0 deletions

64
lua/autocmds.lua Normal file
View File

@@ -0,0 +1,64 @@
--
-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║
-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║
-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║
-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
--
-- File: autocmds.lua
-- Description: Autocommand functions
-- Author: Kien Nguyen-Tuan <kiennt2609@gmail.com>
-- Define autocommands with Lua APIs
-- See: h:api-autocmd, h:augroup
local autocmd = vim.api.nvim_create_autocmd -- Create autocommand
-- General settings
-- Highlight on yank
autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank {
higroup = "IncSearch",
timeout = "1000",
}
end,
})
-- Remove whitespace on save
autocmd("BufWritePre", {
pattern = "",
command = ":%s/\\s\\+$//e",
})
-- Auto format on save using the attached (optionally filtered) language servere clients
-- https://neovim.io/doc/user/lsp.html#vim.lsp.buf.format()
autocmd("BufWritePre", {
pattern = "",
command = ":silent lua vim.lsp.buf.format()",
})
-- Don"t auto commenting new lines
autocmd("BufEnter", {
pattern = "",
command = "set fo-=c fo-=r fo-=o",
})
autocmd("Filetype", {
pattern = { "xml", "html", "xhtml", "css", "scss", "javascript", "typescript", "yaml", "lua" },
command = "setlocal shiftwidth=2 tabstop=2",
})
-- Set colorcolumn
autocmd("Filetype", {
pattern = { "python", "rst", "c", "cpp" },
command = "set colorcolumn=80",
})
autocmd("Filetype", {
pattern = { "gitcommit", "markdown", "text" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})