When BufEnter fires, how to determine if it is a Telescope prompt?
The current window buffer will have a filetype of ‘TelescopePrompt’
local bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_get_option(bufnr, 'filetype')
As you can see if you actually try autocmd, the file type is not set at the time of BufEnter.
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*",
callback = function()
print(vim.api.nvim_buf_get_option(0, "filetype"))
end,
})
Can BufWinEnter be used?
My goal is not to do anything to telescope’s buffer, but to exclude telescope’s buffer from BufEnter’s processing.
It seems telescope is setting the options after the fact, you can wait a cycle with:
vim.schedule(function()
print(vim.api.nvim_buf_get_option(0, "filetype"))
end)
Otherwise you can get the buffers window and check for things like height of 1, if it’s floating, etc with vim.api.nvim_win_get_config
2 Likes
I have solved the problem in another way. Thank you.
Ran into a similar problem customizing some neogit bindings in the commit ui.
Found:
(vim.api.nvim_create_augroup :JNeogitBindings {:clear true})
(vim.api.nvim_create_autocmd
:Filetype
{:group :JNeogitBindings
:pattern :NeogitCommitMessage
:callback neogit-bindings})
Was the solution you found something like that?
1 Like