37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
-- [[ Autocommands ]]
|
|
-- See `:help autocmd`
|
|
-- See `:help lua-guide-autocommands`
|
|
|
|
-- Instantly move help window to the right
|
|
-- This is almost certainly a hacky way to do this)
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
pattern = { 'help' },
|
|
command = 'wincmd L',
|
|
})
|
|
|
|
-- Highlight when yanking (copying) text
|
|
-- Try it with `yap` in normal mode
|
|
-- See `:help vim.highlight.on_yank()`
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
desc = 'Highlight when yanking (copying) text',
|
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
|
callback = function()
|
|
vim.highlight.on_yank()
|
|
end,
|
|
})
|
|
|
|
-- Jump to last edit position when opening a file
|
|
vim.api.nvim_create_autocmd('BufReadPost', {
|
|
callback = function()
|
|
local mark = vim.api.nvim_buf_get_mark(0, '"') -- the '"' mark stores last position
|
|
local line = mark[1]
|
|
local col = mark[2]
|
|
local last_line = vim.api.nvim_buf_line_count(0)
|
|
-- Only jump if the line exists in the file
|
|
if line > 0 and line <= last_line then
|
|
vim.api.nvim_win_set_cursor(0, { line, col })
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- vim: ts=2 sts=2 sw=2 et
|