-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn off cmp in TelescopePrompt buffer? #60
Comments
By default, when buftype is prompt, no completion will be shown. nvim-cmp/lua/cmp/utils/check.lua Line 5 in 46e5d16
|
@uga-rosa is correct. @brandoncc I think nvim-cmp already disabled if the buftype is `prompt. So I want a more detailed explanation of this problem. |
that seems to be sourced from tabnine ( due to the percentage showing), wanted to mention cause that might be related |
It seems to telescope add |
@brandoncc You can set up like this. autocmd FileType TelescopePrompt lua require'cmp'.setup.buffer {
\ completion = { autocomplete = false }
\ } |
Ah, so the |
Could you update nvim-cmp to the latest? |
Thanks, that fixed the error above but the menu still shows up. At this point, I have added all of these: autocmd FileType TelescopePrompt lua print('In TelP')
autocmd FileType TelescopePrompt lua require'cmp'.setup.buffer {
\ completion = { autocomplete = false }
\ }
autocmd FileType TelescopePrompt lua require'cmp_tabnine.config'.setup {
\ max_lines = 0
\ max_num_results = 0
\ } The menu still pops up, but as @abzcoding mentioned, they only seem to be sourced from tabnine for some reason. I thought the code might not be executing, so I added the I also tried hacking around the issue like this: autocmd FileType TelescopePrompt set ft=prompt as well as autocmd FileType TelescopePrompt lua require'cmp'.setup.buffer {
\ completion = { sources = {} }
\ } Those didn't fix the issue either. If it helps, here is my config: " Setup global configuration. More on configuration below.
lua <<EOF
local cmp = require('cmp')
cmp.setup {
snippet = {
expand = function(args)
-- You must install `vim-vsnip` if you use the following as-is.
vim.fn['vsnip#anonymous'](args.body)
end
},
-- You must set mapping if you want.
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
-- You should specify your *installed* sources.
sources = {
{ name = 'buffer' },
{ name = 'nvim_lsp' },
{ name = 'cmp-tabnine' },
{ name = 'path' },
{ name = 'calc' }
},
}
EOF
" Setup buffer configuration (nvim-lua source only enables in Lua filetype).
autocmd FileType lua lua require'cmp'.setup.buffer {
\ sources = {
\ { name = 'buffer' },
\ { name = 'nvim_lua' },
\ },
\ }
autocmd FileType TelescopePrompt lua print('In TelP')
autocmd FileType TelescopePrompt lua require'cmp'.setup.buffer {
\ completion = { autocomplete = false }
\ }
autocmd FileType TelescopePrompt lua require'cmp_tabnine.config'.setup {
\ max_lines = 0
\ max_num_results = 0
\ } |
Even with the configuration pasted at the end of my last comment, I just experienced path completions in the telescope prompt. |
buftype is NOT filetype. Please see |
I'm not sure anyone thought buftype and filetype were the same? |
So, why this?
You have replaced filetype from TelescopePrompt to prompt... |
Ha, touché! I missed the fact that buftype was ever mentioned, and we just thinking about filetype. I didn't understand why you randomly said buftype is not filetype. Your comment makes a lot more sense now 👍 I'll try that hack again with it fixed to set buftype instead of filetype. |
autocmd FileType TelescopePrompt set bt=prompt This didn't help. |
We told that cmp looks at the buftype, not filetype, and disables itself by default. And telescope have done this setting properly. |
I got completions for multiple sources when I have tried everything to turn it off. Thanks for your time, I think I'll move on at this point. |
I updated today and this is fixed, thank you! |
Actually, the problem still happens... I didn't have cmp-tabnine configured right so it wasn't working at all. One day I'll figure out how to fix it.... |
This one helped me. Thank you! |
This works:
|
for me the following worked a bit better: cmp.setup({
enabled = function ()
buftype = vim.api.nvim_buf_get_option(0, "buftype")
if buftype == "prompt" then return false end
return true
end
}) |
I also found annoying that cmp kept showing when writing comments in code, I disabled it as well using treesitter. |
I also came across this issue, where in the telescope buffer we will get the cmp mappings on top of the telescope ones, and for telescope for example will get overriden by the cmp . There has been a change in the default method some 9 monts ago here - 801a9f9#diff-df823ce65cc2c7da6baceae5eeff942546e46b84c95571d897f0ba2f9f0385dd Note that this also happens only in nvim 0.8, in 0.7 it works fine, which is weird, maybe something is broken upstream |
Hello,
Thanks for this awesome plugin. I could never get tab to navigate the menu compe and it does it out of the box with cmp. That alone is worth switching!
I apologize if this is the wrong place to ask, but is there an easy way to turn off compe suggestions while in a TelescopePrompt buffer?
Thanks
The text was updated successfully, but these errors were encountered: