45 lines
1.3 KiB
Lua
45 lines
1.3 KiB
Lua
function nvim_create_augroups(definitions)
|
|
for group_name, definition in pairs(definitions) do
|
|
vim.cmd('augroup ' .. group_name)
|
|
vim.cmd('autocmd!')
|
|
for _, def in ipairs(definition) do
|
|
local command = table.concat(vim.tbl_flatten({ 'autocmd', def }), ' ')
|
|
vim.cmd(command)
|
|
end
|
|
vim.cmd('augroup END')
|
|
end
|
|
end
|
|
|
|
local autocmds = {
|
|
packer = {
|
|
{ 'BufWritePost', 'plugins.lua', 'PackerCompile' },
|
|
},
|
|
restore_cursor = {
|
|
{ 'BufRead', '*', [[call setpos(".", getpos("'\""))]] },
|
|
},
|
|
save_shada = {
|
|
{ 'FocusGained,FocusLost', '*', 'rshada|wshada' },
|
|
},
|
|
resize_windows_proportionally = {
|
|
{ 'VimResized', '*', ':wincmd =' },
|
|
},
|
|
lua_highlight = {
|
|
{ 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] },
|
|
},
|
|
file_type = {
|
|
{ 'BufRead,BufNewFile', '*.simvis', 'set filetype=xml' },
|
|
{ 'BufRead,BufNewFile', '*.simcfg,*.simcon,*.simudex', 'set filetype=cfg' },
|
|
{ 'BufRead,BufNewFile', 'Jenkinsfile*', 'set filetype=groovy' },
|
|
{ 'BufRead,BufNewFile', '*.manifest', 'set filetype=xml' },
|
|
{ 'BufRead,BufNewFile', 'SConstruct,SConscript', 'set filetype=python' },
|
|
},
|
|
file_changed = {
|
|
{ 'BufEnter,FocusGained', '*', 'checktime' },
|
|
},
|
|
no_auto_comment = {
|
|
{ 'BufEnter', '*', 'set fo-=c fo-=r fo-=o' },
|
|
},
|
|
}
|
|
|
|
nvim_create_augroups(autocmds)
|