tzachar / cmp-tabnine

TabNine plugin for hrsh7th/nvim-cmp
MIT License
286 stars 27 forks source link

can't use :CmpTabnineHub command in wsl #77

Closed HUAHUAI23 closed 1 year ago

HUAHUAI23 commented 1 year ago

when i use :CmpTabnineHub in wsl2 (ubuntu) , a error message ...pack/packer/start/cmp-tabnine/lua/cmp_tabnine/source.lua:306: attempt to call method 'find' (a nil value) appears

image

tzachar commented 1 year ago

This is very strange. Which version of nvim are you using? And what is the output of : lua print(string.find) ?

HUAHUAI23 commented 1 year ago

my nvim version is 8.0 图片

the output of : lua print(string.find) is function

https://user-images.githubusercontent.com/43649186/202374259-3f7e6cd4-59ba-45da-998c-e98d8cec57e3.mp4

tzachar commented 1 year ago

Again, very strange. I'll try to debug it on WSL.

HUAHUAI23 commented 1 year ago

Many thanks this is my minimal configure

local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
    local path_sep = on_windows and "\\" or "/"
    local result = table.concat({ ... }, path_sep)
    return result
end

vim.cmd([[set runtimepath=$VIMRUNTIME]])

local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"
temp_dir = temp_dir .. "/neovimtest"
vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local function load_plugins()
    require("packer").startup({
        function(use)
            use("ajmwagar/vim-deus")
            use("wbthomason/packer.nvim")
            use("hrsh7th/nvim-cmp") --completion
            use({ "tzachar/cmp-tabnine", run = "./install.sh", requires = "hrsh7th/nvim-cmp" })
        end,
        config = {
            package_root = package_root,
            compile_path = compile_path,
        },
    })
end

local function load_config()
    vim.o.t_Co = 256
    vim.o.termguicolors = true
    vim.cmd([[colorscheme deus]])
    local tabnine = require("cmp_tabnine.config")
    tabnine:setup({
        max_lines = 1000,
        max_num_results = 20,
        sort = true,
        run_on_every_keystroke = true,
        snippet_placeholder = "..",
        ignored_file_types = {
            -- default is not to ignore
            -- uncomment to ignore in lua:
            -- lua = true
        },
        show_prediction_strength = false,
    })
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
    load_plugins()
    require("packer").sync()
    local packer_group = vim.api.nvim_create_augroup("Packer", { clear = true })
    vim.api.nvim_create_autocmd(
        "User",
        { pattern = "PackerComplete", callback = load_config, group = packer_group, once = true }
    )
else
    load_plugins()
    -- require("packer").sync()
    load_config()
end

图片

tzachar commented 1 year ago

I could not reproduce this under WSL.