.dotfiles/.config/nvim/lua/tiagorg/autocmd.lua

25 lines
721 B
Lua
Raw Normal View History

vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = {"*"},
callback = function()
local save_cursor = vim.fn.getpos(".")
vim.cmd([[%s/\s\+$//e]])
vim.fn.setpos(".", save_cursor)
end,
})
vim.api.nvim_create_autocmd({"CmdlineLeave", "CmdlineChanged"}, {
group = vim.api.nvim_create_augroup("SearchHighlight", { clear = true }),
pattern = { "/", "\\?" },
callback = function()
vim.cmd([[nnoremap <buffer> <Esc> :noh<CR>]])
end
})
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight yanked text",
group = vim.api.nvim_create_augroup("HighlightYank", { clear = true}),
callback = function()
vim.highlight.on_yank()
end
})