Files
nvim/lua/config/autocmd.lua
2024-10-02 10:04:04 +02:00

35 lines
819 B
Lua

vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
-- return to last cursor position when reopening a file
vim.api.nvim_create_autocmd('BufReadPost', {
callback = function()
local last_pos = vim.fn.line '\'"'
if last_pos > 1 and last_pos <= vim.fn.line '$' then
vim.cmd 'normal! g`"'
end
end,
})
vim.api.nvim_create_autocmd('FileType', {
pattern = {
'checkhealth',
'fugitive*',
'git',
'help',
'lspinfo',
'netrw',
'notify',
'qf',
'query',
},
callback = function()
vim.keymap.set('n', 'q', vim.cmd.close, { desc = 'Close the current buffer', buffer = true })
end,
})