nvim: call lua function directly in autogroup
This commit is contained in:
parent
a74aecc68c
commit
b46408a64a
|
@ -22,19 +22,19 @@ packer.use {
|
|||
}
|
||||
|
||||
-- remove trailing whitespace
|
||||
function remove_trailing_whitespace()
|
||||
function my_remove_trailing_whitespace()
|
||||
local curpos = vim.api.nvim_win_get_cursor(0)
|
||||
vim.cmd([[keeppatterns %s/\s\+$//e]])
|
||||
vim.api.nvim_win_set_cursor(0, curpos)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ "BufWritePre" },
|
||||
{ 'BufWritePre' },
|
||||
{
|
||||
pattern = {
|
||||
"*.lua", "*.cpp", "*.hpp"
|
||||
'*.lua', '*.cpp', '*.hpp'
|
||||
},
|
||||
command = 'lua remove_trailing_whitespace()'
|
||||
callback = my_remove_trailing_whitespace
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user