Closed huwqchn closed 1 year ago
How to reproduce this?
I'm having a similar issue with a setup identical to https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip, pressing Tab key on an empty line does nothing: whereas pressing Shift-Tab acts as if pressing a Tab key (goes forward by a tab)
I'm having a similar issue with a setup identical to https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip, pressing Tab key on an empty line does nothing: whereas pressing Shift-Tab acts as if pressing a Tab key (goes forward by a tab)
Some bug
How to reproduce this?
just setup cmp config exampple https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip will reproduct this, tab cant fallback, but S-tab act as tab
I've hidden my comment because it was due to another plugin Exafunction/codeium.vim
Please provide a complete reproducible configuration example in the issue.
With your example configuration, I got an error that the function jumpable
doesn't exist.
It takes a lot of time and effort.
I believe the steps to reproduce are still not provided. "It doesn't work" doesn't mean anything.
Anyway, I tried the below setting, but <Tab>
was inserted on an empty line.
if has('vim_starting')
set encoding=utf-8
endif
scriptencoding utf-8
if &compatible
set nocompatible
endif
let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end
execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'L3MON4D3/LuaSnip'
Plug 'neovim/nvim-lspconfig'
Plug 'saadparwaiz1/cmp_luasnip'
call plug#end()
PlugInstall | quit
" Setup global configuration. More on configuration below.
lua << EOF
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local cmp = require "cmp"
local luasnip = require('luasnip')
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
}),
}
EOF
Sorry, It's not a bug, In Insert mode, ctrl + i is the same as tab, I was mapping Ctrl + i to some function in insert mode...
FAQ
Announcement
Minimal reproducible full config
Description
Tab can't fallback after update to latest commit
Steps to reproduce
set mapping for tab will make tab never fallback
Expected behavior
Tab fallback when cmp not visible
Actual behavior
tab never fallback
Additional context
No response