tzachar / cmp-tabnine

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

Any reason why cmp-tabnine is so slow? #17

Closed vzytoi closed 2 years ago

vzytoi commented 2 years ago

Hey, I'm using cmp-tabnine since a couple of days (I really love it) and I just realised that this plugin is taking many time to load when I start nvim. I just wanted to know if this was just a problem about my configuration or it's actually slow...

nvim --startuptime start.log:

511.439  160.493  160.493: sourcing C:\Users\Cyprien\AppData\Local\nvim-data\site\pack\packer\start\cmp-tabnine\after\plugin\cmp-tabnine.lua

(it takes 160ms to load)
Thank you and have a nice day! (:

tzachar commented 2 years ago

On my machine it takes less than 6 msecs. This is very strange.

Apart from defining functions in the module, the only thing the module do is this:

local binaries_folder = get_parent_dir(get_parent_dir(script_path())) .. 'binaries'

Doesn't seem like it should take that long.

vzytoi commented 2 years ago

It's really wierd ... It may have something to do with the fact that i'm using a forked version on cmp-tabine (see #16) Here is my configuration :

use {
    'hrsh7th/nvim-cmp',
    config = function()
        require('plugins.cmp').config()
    end,
    requires = {
        'quangnguyen30192/cmp-nvim-ultisnips',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-calc',
        {
            'adrianiy/cmp-tabnine',
            run = './install.sh'
        }
    }
}
local M = {}

local function feedkey(key, mode)
    vim.api.nvim_feedkeys(
        vim.api.nvim_replace_termcodes(key, true, true, true),
    mode, true)
end

function M:config()

    M.cmp = require('cmp')
    M.lspkind = require('lspkind')

    M.cmp.setup {
        snippet = {
            expand = function(args)
                vim.fn['UltiSnips#Anon'](args.body)
            end
        },
        sources = {
            { name = 'cmp_tabnine' },
            { name = 'ultisnips' },
            { name = 'path' },
            { name = 'buffer', keyword_length = 5},
            { name = 'calc' }
        },
        mapping = {
            ['<c-k>'] = M.cmp.mapping.select_prev_item(),
            ['<c-j>'] = M.cmp.mapping.select_next_item(),
            ['<CR>'] = M.cmp.mapping.confirm({
                behavior = M.cmp.ConfirmBehavior.Replace,
                select = true,
            })
        },
        formatting = {
            format = M.lspkind.cmp_format {
                with_text = false,
                menu = {
                    cmp_tabnine = "[tabnine]",
                    ultisnips = "[snip]",
                    buffer = "[buf]",
                    path = "[path]",
                    calc = "[calc]"
                }
            }
        },
        experimental = {
            native_menu = false,
            ghost_text = true
        }
}

end

return M
tzachar commented 2 years ago

I can't help you regarding the fork. Your config looks fine to me. Please contact the fork's author.

tzachar commented 2 years ago

@vzytoi

Check with the latest commit (d52a25d), it might have improved the situation.

vzytoi commented 2 years ago

Yes it does !!! I'm going to make a PR on @adrianiy fork.

179.858  000.290  000.290: sourcing c:\users\cyprien\appdata\local\nvim-data\site\pack\packer\start\cmp-tabnine\after\plugin\cmp-tabnine.lua

I can close this one, tsm for mentioning me, have a nice day (: