local M = {} M.setup = function() -- NOTE: Highlight text yanked vim.api.nvim_create_autocmd('TextYankPost', { callback = function() vim.highlight.on_yank() end, }) -- NOTE: Remove trailing whitespace on save vim.api.nvim_create_autocmd('BufWritePre', { command = '%s/\\s\\+$//e', }) -- NOTE: Handles scenarios in which the filetype isn't detected on load vim.api.nvim_create_autocmd('BufReadPost', { pattern = '*', callback = function(args) local opt_ft = vim.opt_local.ft:get() if opt_ft == nil or opt_ft == '' then local ft = vim.filetype.match({ buf = args.buf }) if ft ~= nil or ft ~= '' then vim.opt_local.ft = ft end end end, }) end return M