local api = vim.api -- Highlight on yank local yankGrp = api.nvim_create_augroup('YankHighlight', { clear = true }) api.nvim_create_autocmd('TextYankPost', { command = 'silent! lua vim.highlight.on_yank()', group = yankGrp, }) vim.filetype.add({ extension = { simvis = 'xml', manifest = 'xml', simcfg = 'xml', simcon = 'xml', simudex = 'xml' }, filename = { ['JenkinsFile'] = 'groovy', ['SConstruct'] = 'python', ['SConscript'] = 'python', ['doskey'] = 'dosini', ['.clangd'] = 'yaml', ['.clang-tidy'] = 'yaml', }, }) -- Read and write shada file api.nvim_create_autocmd({ 'FocusLost' }, { command = [[wshada]] }) -- go to last loc when opening a buffer -- api.nvim_create_autocmd( -- 'BufReadPost', -- { command = [[if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif]] } -- ) -- When editing a file, always jump to the last known cursor position. -- Don't do it when the position is invalid, when inside an event handler -- (happens when dropping a file on gvim) and for a commit message (it's -- likely a different one than last time). local userGrp = api.nvim_create_augroup('UserGroup', { clear = true }) vim.api.nvim_create_autocmd('BufReadPost', { group = userGrp, callback = function(args) local valid_line = vim.fn.line([['"]]) >= 1 and vim.fn.line([['"]]) < vim.fn.line('$') local not_commit = vim.b[args.buf].filetype ~= 'commit' if valid_line and not_commit then vim.cmd([[normal! g`"]]) end end, }) -- Check if we need to reload the file when it changed api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' }, { command = [[if !bufexists("[Command Line]") | checktime | endif]] }) -- windows to close with "q" api.nvim_create_autocmd('FileType', { pattern = { 'help', 'startuptime', 'qf', 'lspinfo' }, command = [[nnoremap q :close]] }) api.nvim_create_autocmd('FileType', { pattern = 'man', command = [[nnoremap q :quit]] }) -- don't auto comment new line api.nvim_create_autocmd('BufEnter', { command = [[set formatoptions-=cro]] }) -- Keep window ratio when resize api.nvim_create_autocmd('VimResized', { command = [[wincmd =]] })