I have a autocmd for centralize the cursor, but whichkey show a warning. #853
-
this is my autocmd for centralize the cursor: local function is_telescope_visible()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
local buf = vim.api.nvim_win_get_buf(win)
local filetype = vim.api.nvim_buf_get_option(buf, "filetype")
if filetype == "TelescopePrompt" then
return true
end
end
return false
end
vim.api.nvim_create_autocmd(
{"CursorMoved", "CursorMovedI", "InsertChange", "DiagnosticChanged", "InsertEnter", "InsertLeave"},
{
desc = "Center cursor",
group = vim.api.nvim_create_augroup("CenterCursor", {clear = true}),
callback = function()
local line = vim.api.nvim_win_get_cursor(0)[1]
local column = vim.api.nvim_win_get_cursor(0)[2]
local mode = vim.fn.mode(1)
if is_telescope_visible() then
return
end
if mode == "i" then
vim.cmd.normal("zz")
vim.api.nvim_win_set_cursor(0, {line, column})
return
end
if line ~= vim.b.last_line then
vim.cmd.normal("zz")
end
end
}
) and this is the warning:
any idea? |
Beta Was this translation helpful? Give feedback.
Answered by
oaSakamoto
Sep 24, 2024
Replies: 1 comment
-
Hey guys a make a mistake in the autocmd, and find now, i change the vim.cmd function and solve the problem: vim.cmd.normal("zz") for: vim.cmd('normal! zz') |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
oaSakamoto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey guys a make a mistake in the autocmd, and find now, i change the vim.cmd function and solve the problem:
for: