-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
autocmds.lua
30 lines (27 loc) · 862 Bytes
/
autocmds.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local group = vim.api.nvim_create_augroup('Setup', {})
-- Highlight text after yanking
vim.api.nvim_create_autocmd('TextYankPost', {
group = group,
callback = function()
require('vim.highlight').on_yank { higroup = 'Substitute', timeout = 200 }
end,
})
-- Automatically close Vim if the quickfix window is the only one open
vim.api.nvim_create_autocmd('WinEnter', {
group = group,
callback = function()
if vim.fn.winnr '$' == 1 and vim.fn.win_gettype() == 'quickfix' then
vim.cmd.q()
end
end,
})
vim.api.nvim_create_autocmd('BufReadPost', {
desc = 'Open file at the last position it was edited earlier',
group = group,
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
if mark[1] > 1 and mark[1] <= vim.api.nvim_buf_line_count(0) then
vim.api.nvim_win_set_cursor(0, mark)
end
end,
})