tzachar / cmp-tabnine

TabNine plugin for hrsh7th/nvim-cmp
MIT License
288 stars 28 forks source link

Overlapping completion sources #105

Closed kflak closed 8 months ago

kflak commented 8 months ago

Hi,

Trying to get tabnine working for using a dictionary, but it's conflicting with my other sources, see screenshot: 2024-02-21_08:52:24

nvim version:

NVIM v0.10.0-dev-2394+g1c520053a9
Build type: RelWithDebInfo
LuaJIT 2.1.1702233742

nvim-cmp config:

return {
    'hrsh7th/nvim-cmp',
    config = function()
        local cmp = require'cmp'
        local lspkind = require'lspkind'
        local ls = require("luasnip")
        lspkind.init()

        cmp.setup {
            snippet = {
                expand = function(args)
                    require('luasnip').lsp_expand(args.body)
                end,
            },
            mapping = cmp.mapping.preset.insert({
                ['<C-Space>'] = cmp.mapping.complete,
                ['<C-e>'] = cmp.mapping({
                    i = cmp.mapping.abort(),
                    c = cmp.mapping.close(),
                }),
                ['<CR>'] = cmp.mapping.confirm({
                    select = true,
                }),
                ["<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 = {
                { name = 'luasnip' },
                { name = 'nvim_lsp' },
                { name = 'dictionary' },
                { name = 'path', keyword_length = 1 },
                { name = 'tags' },
                { name = 'buffer' },
                { name = 'conjure'},
                { name = 'neorg'},
            },
            formatting = {
                format = lspkind.cmp_format {
                    with_text = true,
                    menu = {
                        luasnip = '[snip]',
                        nvim_lsp = '[LSP]',
                        dictionary = '[dict]',
                        path = '[path]',
                        tags = '[tags]',
                        buffer = '[buf]',
                    },
                },
            },
            completion = {
                keyword_length = 2,
            },
            view = {
                native_menu = true
            },
        }

        cmp.setup.filetype("tex", {
            sources = {
                { name = 'vimtex' },
                { name = 'buffer' },
            }
        })

        vim.keymap.set({"i", "s"}, "<C-L>", function() ls.jump( 1) end, {silent = true})
        vim.keymap.set({"i", "s"}, "<C-J>", function() ls.jump(-1) end, {silent = true})

        vim.keymap.set({"i", "s"}, "<C-E>", function()
            if ls.choice_active() then
                ls.change_choice(1)
            end
        end, {silent = true})

        require('luasnip.loaders.from_vscode').lazy_load()
        require("luasnip.loaders.from_lua").lazy_load({paths = "~/.config/nvim/lua/snippets"})
    end,
    dependencies = {
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-nvim-lua',
        'hrsh7th/cmp-nvim-lsp',
        'hrsh7th/cmp-path',
        'quangnguyen30192/cmp-nvim-tags',
        'onsails/lspkind-nvim',
        'saadparwaiz1/cmp_luasnip',
        'lukas-reineke/cmp-rg',
        'hrsh7th/cmp-calc',
        'rafamadriz/friendly-snippets',
        'madskjeldgaard/vim-scdoc-snippets',
        'uga-rosa/cmp-dictionary',
        'micangl/cmp-vimtex',
        {
            'tzachar/cmp-tabnine',
            build = './install.sh',
        }
    }
}

coc.nvim config:

return {
    'neoclide/coc.nvim',
    branch = 'release',
    ft = "lilypond"
}

System: Arch linux 6.7.5

Grateful for any help!

tzachar commented 8 months ago

I think this is coc.nvim clashing with cmp. You can't have them both work using the same trigger. Choose either one or the other, or configure different triggers.

Anyway, I don't think this has anything to do with this plugin.

kflak commented 8 months ago

Good good. I found another way of doing what I need to do without having to resort to coc :-) Getting a little bit too many AIs in my nvim these days anyway.