-- resize splits if window got resized vim.api.nvim_create_autocmd({ "VimResized" }, { callback = function() vim.cmd "tabdo wincmd =" end, }) -- close some filetypes with vim.api.nvim_create_autocmd("FileType", { pattern = { "qf", "help", "man", "notify", "lspinfo", "spectre_panel", "startuptime", "tsplayground", "PlenaryTestPopup", }, callback = function(event) vim.bo[event.buf].buflisted = false vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) end, }) vim.api.nvim_create_autocmd("FileType", { pattern = { "gitcommit", "markdown", "NeogitCommitMessage", "norg" }, callback = function() vim.opt_local.wrap = true vim.opt_local.spell = true end, }) vim.api.nvim_create_autocmd({ "BufWritePre" }, { callback = function() vim.cmd [[%s/\s\+$//e]] end, }) -- Función para alternar el ajuste de línea function ToggleWrap() local wrap = vim.wo.wrap vim.wo.wrap = not wrap if vim.wo.wrap then print "Ajuste de línea: Habilitado" else print "Ajuste de línea: Deshabilitado" end end vim.api.nvim_create_autocmd("BufEnter", { pattern = "*", callback = function() if vim.opt.diff:get() then local wk = require "which-key" local opts = { mode = "n", -- NORMAL mode buffer = vim.api.nvim_get_current_buf(), -- Specify a buffer number for buffer local mappings } local mappings = { [""] = { --- get from REMOTE ["1"] = { ":diffget LOCAL", "Get LOCAL" }, --- get from BASE ["2"] = { ":diffget BASE", "Get BASE" }, --- get from LOCAL ["3"] = { ":diffget REMOTE", "Get REMOTE" }, }, } wk.register(mappings, opts) end end, }) -- 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 -- local function augroup(name) return vim.api.nvim_create_augroup("my_lazyvim_" .. name, { clear = true }) end -- Set filetype for .env and .env.* files vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { group = augroup("env_filetype"), pattern = { "*.env", ".env.*" }, callback = function() vim.opt_local.filetype = "sh" end, }) -- Set filetype for .hurl files vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { group = augroup("hurl_filetype"), pattern = { "*.hurl" }, callback = function() vim.opt_local.filetype = "hurl" end, }) -- Set filetype for .toml files vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { group = augroup("toml_filetype"), pattern = { "*.tomg-config*" }, callback = function() vim.opt_local.filetype = "toml" end, }) -- Set filetype for .ejs files vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { group = augroup("ejs_filetype"), pattern = { "*.ejs", "*.ejs.t" }, callback = function() vim.opt_local.filetype = "embedded_template" end, })