58 lines
1.2 KiB
Lua
58 lines
1.2 KiB
Lua
local function auto(event, opts)
|
|
a.nvim_create_autocmd(event, opts)
|
|
end
|
|
|
|
a.nvim_create_augroup('bufcheck', {clear = true})
|
|
|
|
-- highlight yanks
|
|
auto('TextYankPost', {
|
|
group = 'bufcheck',
|
|
pattern = '*',
|
|
callback = function()
|
|
vim.highlight.on_yank{ timeout = 250 }
|
|
end
|
|
})
|
|
|
|
-- start git messages in insert mode
|
|
auto('FileType', {
|
|
group = 'bufcheck',
|
|
pattern = { 'gitcommit', 'gitrebase', },
|
|
command = 'startinsert | 1'
|
|
})
|
|
|
|
-- return to last place
|
|
auto('BufRead', {
|
|
pattern = '*',
|
|
command = [[call setpos(".", getpos("'\""))]]
|
|
})
|
|
|
|
-- start terminal in insert mode
|
|
auto('TermOpen', {
|
|
group = 'bufcheck',
|
|
pattern = '*',
|
|
callback = function()
|
|
vim.cmd('startinsert | set winfixheight')
|
|
o.winfixheight = true
|
|
o.cmdheight = 0
|
|
end
|
|
})
|
|
|
|
-- close terminal buffers after shell dies
|
|
auto('TermClose', {
|
|
group = 'bufcheck',
|
|
pattern = 'term://*',
|
|
callback = function()
|
|
vim.cmd('call nvim_input("<CR>")')
|
|
o.cmdheight = 1
|
|
end
|
|
})
|
|
|
|
auto('BufWritePre', { -- make dirs when they don't exist
|
|
pattern = '*',
|
|
group = vim.api.nvim_create_augroup('auto_create_dir', { clear = true }),
|
|
callback = function(ctx)
|
|
local dir = vim.fn.fnamemodify(ctx.file, ':p:h')
|
|
vim.fn.mkdir(dir, 'p')
|
|
end
|
|
})
|