centerscroll: use lua to filter buftypes

This commit is contained in:
Alexander Gehrke 2023-08-21 13:54:27 +02:00
parent f3923dd425
commit 6e1060fbaf
2 changed files with 16 additions and 5 deletions

View file

@ -1,5 +0,0 @@
" from https://vi.stackexchange.com/a/26055
augroup KeepCentered
autocmd!
autocmd CursorMoved * normal! zz
augroup END

16
plugin/centerscroll.lua Normal file
View file

@ -0,0 +1,16 @@
-- " from https://vi.stackexchange.com/a/26055
-- augroup KeepCentered
-- autocmd!
-- autocmd CursorMoved * if &buftype == '' | normal! zz | endif
-- augroup END
vim.api.nvim_create_augroup("KeepCentered", { clear = true })
vim.api.nvim_create_autocmd("CursorMoved", {
group = "KeepCentered",
pattern = '*',
callback = function()
if vim.o.buftype == '' then
vim.cmd([[normal! zz]])
end
end,
})