-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocmds.lua
66 lines (59 loc) · 1.41 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local utils = require('utils')
local autocmd = utils.autocmd
local nmap = utils.nmap
autocmd('VimResized', {
callback = function()
vim.cmd('tabdo wincmd =')
end,
})
-- Close some filetypes with <q>
autocmd('FileType', {
pattern = {
'qf',
'help',
'checkhealth',
'git',
},
callback = function(event)
vim.bo[event.buf].buflisted = false
nmap('q', '<cmd>close<cr>', { buffer = event.buf })
end,
})
-- Autoclose lsp quickfix list when select item with <e>
autocmd('FileType', {
pattern = 'qf',
callback = function()
local bufnr = vim.fn.bufnr('%')
nmap('e', function()
vim.api.nvim_command([[execute "normal! \<cr>"]])
vim.api.nvim_command(bufnr .. 'bd')
end, { buffer = bufnr })
end,
})
-- set foldmethod=marker for .conf files
autocmd('FileType', {
pattern = 'conf',
callback = function()
vim.wo.foldmethod = 'marker'
end,
})
autocmd('TermOpen', {
callback = function()
vim.opt_local.number = false
vim.opt_local.relativenumber = false
vim.opt_local.signcolumn = 'no'
vim.opt_local.foldcolumn = '0'
end,
})
autocmd('TermClose', {
callback = function()
vim.cmd("execute 'bdelete! ' . expand('<abuf>')")
end,
})
-- highlight copied (yanked) text
autocmd('TextYankPost', {
group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank({ higroup = 'HighlightYank' })
end,
})