This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
neovim autocommands got merged, describe them in guide #100
Comments
For something useful and minimal, you could provide vim.api.nvim_create_augroup({ name = 'MYAUCMDS', clear = true })
-- text yank highlighting
vim.api.nvim_create_autocmd({ group='MYAUCMDS', event = 'TextYankPost', pattern = '*', command = [[silent! lua require'vim.highlight'.on_yank({timeout = 100})]], })
-- remove trailing spaces
vim.api.nvim_create_autocmd({ group='MYAUCMDS', event = 'BufWritePre', pattern = '*', command = [[:%s/\s\+$//e]] }) |
With the latest breaking change, this is now vim.api.nvim_create_augroup('MYAUCMDS', {clear = true})
vim.api.nvim_create_autocmd('TextYankPost', {group = 'MYAUCMDS', pattern = '*', command = [[silent! lua require'vim.highlight'.on_yank({timeout = 100})]]})
vim.api.nvim_create_autocmd('BufWritePre', {group = 'MYAUCMDS', pattern = '*', command = [[:%s/\s\+$//e]]}) -- remove trailing spaces
|
vim.api.nvim_create_autocmd('TextYankPost', {group = 'MYAUCMDS', pattern = '*', command = [[silent! lua require'vim.highlight'.on_yank({timeout = 100})]]}) This one isn't correct although it works. You can use vim.api.nvim_create_autocmd('TextYankPost', {group = 'MYAUCMDS', pattern = '*', callback = function() require'vim.highlight'.on_yank({timeout = 100}) end}) or even vim.api.nvim_create_autocmd('TextYankPost', {group = 'MYAUCMDS', pattern = '*', callback = require'vim.highlight'.on_yank}) if there is no need to pass any arguments. |
Also works for buffers now: neovim/neovim#17594 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
neovim/neovim#14661 (lua: autocmds take 2)
see also the not yet merged PR on the docs: https://github.com/neovim/neovim/pull/17545/files
The text was updated successfully, but these errors were encountered: