Comments (4)
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 callback
instead of `command:
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.
from nvim-lua-guide.
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
from nvim-lua-guide.
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]] })
from nvim-lua-guide.
Also works for buffers now: neovim/neovim#17594
from nvim-lua-guide.
Related Issues (20)
- threading support for lua via libuv got merged, link to good tutorial on usage
- suggestions on how to reload keymaps and options
- How to get &ft from lua HOT 4
- Describe how to create user commands that support ranges
- explain that `vim.api.nvim_set_keymap(mode, ..)` is first char of `:lua print(vim.api.nvim_get_mode().mode)` and hint that there is a minor mode HOT 2
- FFI Library: calling native C function
- Remove problematic flags emoji
- Can we use this guide in Neovim? HOT 3
- Add a Table of content HOT 1
- add protected call for make sure the first run will work properlly
- add recommended formatter setup for lua and nvim lua plugin template
- Question: lua replacement for `executable()`? HOT 2
- how to read the command arguments `:command arg1 arg2` with lua HOT 2
- vim.api.nvim_exec() example gives error HOT 1
- lua user commands pr landed, so describe them in guide HOT 1
- Improper handling of relative paths with spaces HOT 2
- How to let `vim.cmd` accept the range from visual selection HOT 1
- Create keymap to open new file adjacent to current file HOT 6
- DEPRECATED replaced by mode option HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-lua-guide.