hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
550 stars 42 forks source link

Super Tab binding stopped working after updating nvim-cmp #41

Closed shubham-cpp closed 2 years ago

shubham-cpp commented 2 years ago

I've Ctrl-n and Ctrl-p mapping which works fine for search and cmd mode. But the Tab binding has stopped working

Cmp setup. ```lua local has_words_before = function() 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 feedkey = function(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end cmp.setup({ ...., mapping = cmp.mapping.preset.insert({ ... [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-expand-or-jump)", "") elseif has_words_before() then cmp.complete() else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function() if cmp.visible() then cmp.select_next_item() else cmp.complete() end end, { "i", "c" }), }), .... }) cmp.setup.cmdline("/", { -- completion = { autocomplete = false }, sources = { -- { name = 'buffer' } { name = "buffer", opts = { keyword_pattern = [=[[^[:blank:]].*]=] } }, }, }) cmp.setup.cmdline(":", { completion = { autocomplete = false }, entries = {name = 'custom'--[[ , separator = '|' ]] } sources = cmp.config.sources({ { name = "path" }, }, { { name = "cmdline" }, }), }) ```

Note: I use vsnip

shubham-cpp commented 2 years ago

Fixed the issue. Must add

    cmp.setup.cmdline(":", {
    -- mapping = cmp.mapping.preset.cmdline(),
    completion = { autocomplete = false },
    sources = sources({
        { name = "path" },
    }, {
        { name = "cmdline" },
    }),
    mapping = cmp.mapping.preset.cmdline({}),   -- This line
})
prdanelli commented 2 years ago

Would it be worth adding this to the Readme? I couldn't work out why my normal bindings weren't working for the cmdline plugin and had to dig around through closed issues to see if it was a solved issue.