zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.54k stars 72 forks source link

Copilot.lua + copilot-cmp not working #20

Closed enzom-uy closed 2 years ago

enzom-uy commented 2 years ago

Hi! I just found out about copilot.lua and copilot-cmp on Reddit and installed them. I have the folder in ~/.config/github-copilot with both hosts.json and terms.json, but I'm not getting anything from copilot-cmp.

I already read #10 but nothing there was useful for me :(

Edit: I'm using neovim v0.7.0dev

This is all the config related to Copilot.lua and copilot-cmp, is an awful combination of configs since I've been trying for a couple of hours:

plugins.lua:

  use {
    "zbirenbaum/copilot.lua",
    event = { "VimEnter" },
    config = function()
      vim.defer_fn(function()
        require("copilot").setup({
          plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
          server_opts_overrides = {},
          ft_disable = { "markdown" }
        })
      end, 100)
    end,
  }
  use {
    "zbirenbaum/copilot-cmp",
    after = { "copilot.lua", "nvim-cmp" },
  }

cmp config:

local cmp = require("cmp")
cmp.setup{
  window = {
    completion = {
      border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
      scrollbar = "║",
      autocomplete = {
        require("cmp.types").cmp.TriggerEvent.InsertEnter,
        require("cmp.types").cmp.TriggerEvent.TextChanged,
      },
    },
    documentation = {
      border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
      winhighlight = "NormalFloat:NormalFloat,FloatBorder:FloatBorder",
      scrollbar = "║",
    },
  },
  config = {
    sources = {
      { name = 'copilot' }
    }
  },

  sources = {
    { name = "nvim_lsp", group_index = 2 },
    { name = "luasnip", group_index = 2 },
    { name = "cmp_tabnine", group_index = 2 },
    { name = "copilot", group_index = 2 },
    { name = "buffer", group_index = 2 },
  },
  formatting = {
    format = function(entry, vim_item)
      -- Kind icons
      vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
      -- Source
      vim_item.menu = ({
        buffer = "[Buffer]",
        nvim_lsp = "[LSP]",
        luasnip = "[LuaSnip]",
        copilot = "[Copilot]",
        cmp_tabnine = "[TabNine]"
      })[entry.source.name]
      return vim_item
    end
  },
  snippet = {
    expand = function(args)
      require("luasnip").lsp_expand(args.body)
    end,
  },
  enabled = function()
    -- disable completion in comments
    local context = require("cmp.config.context")
    return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
  end,
  mapping = {
    ["<C-p>"] = cmp.mapping.select_prev_item(),
    ["<C-n>"] = cmp.mapping.select_next_item(),
    ["<C-d>"] = cmp.mapping.scroll_docs(-4),
    ["<C-f>"] = cmp.mapping.scroll_docs(4),
    ["<C-Space>"] = cmp.mapping.complete(),
    ["<C-e>"] = cmp.mapping.close(),
    ["<CR>"] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    }),
    ["<Tab>"] = function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif vim.fn["vsnip#available"](1) > 0 then
        -- handle vsnip
      else
        fallback()
      end
    end,
    ["<S-Tab>"] = function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      elseif ls.jumpable(-1) then
        ls.jump(-1)
      else
        fallback()
      end
    end,
  },
}
zbirenbaum commented 2 years ago

That is very interesting, just to confirm, cmp provides other completions and copilot.vim functioned fine?

Could you check :LspInfo and see if copilot shows up there? And if so if it's attached?

kozer commented 2 years ago

@zbirenbaum this is something I noticed yesterday as well. For some reason (not sure if related) copilot stopped attaching to buffer. NVIM v0.7.0-dev+1453-g8486c87e5 Other completions work as expected for me

NOTE: I noticed that if i open directly the file copilot attached. So for some reason I assume it doesnet attach to new buffers?

enzom-uy commented 2 years ago

That is very interesting, just to confirm, cmp provides other completions and copilot.vim functioned fine?

@zbirenbaum Yup, everything else is working.

Could you check :LspInfo and see if copilot shows up there? And if so if it's attached?

There's nothing about Copilot from what I can understand:

Hmm, you have packer sync'd correct? Try calling it on startup, as in remove event from packer and set config to just require("copilot").setup() with no defer or anything.

If you packer sync after that and don't notice a slow startup there's something very wrong.

If you aren't afraid to get a bit technical, I can provide some instructions on installing and using my dev branch which can provide some more info

enzom-uy commented 2 years ago

I just noticed you edited my comment, my bad lol. Yup I have my packer sync'd.

Changed the config to call it on startup and now :LspInfo shows something new, so there's progress :)

If you want to give me some instructions to use your dev branch I have no problem with that

kozer commented 2 years ago

Inspired by your code @zbirenbaum I did the following and everything seems to work again

local copilot_attach = vim.api.nvim_create_augroup("copilot_attach",
                                                   {clear = true})

vim.api.nvim_create_autocmd({"BufEnter"}, {
    pattern = "*",
    group = copilot_attach,
    callback = function()
        local client_id = require("copilot.util").find_copilot_client()
        if vim.api.nvim_get_current_buf() ~= nil and vim.bo.filetype ~= "" and
            client_id then vim.lsp.buf_attach_client(0, client_id) end
    end
})

Can you check it enzom-uy?

zbirenbaum commented 2 years ago

Inspired by your code I did the following and everything seems to work again

local copilot_attach = vim.api.nvim_create_augroup("copilot_attach",
                                                   {clear = true})

vim.api.nvim_create_autocmd({"BufEnter"}, {
    pattern = "*",
    group = copilot_attach,
    callback = function()
        local client_id = require("copilot.util").find_copilot_client()
        if vim.api.nvim_get_current_buf() ~= nil and vim.bo.filetype ~= "" and
            client_id then vim.lsp.buf_attach_client(0, client_id) end
    end
})

Awesome, I was just looking at my dev branch to see how to best go about this. I'm pretty curious as to why that would be happening though.

I managed to kinda reproduce the issue when opening a new file (one that doesn't exist yet) and copilot doesn't attach. When I do the same opening a file from cli though its fine. I'm wondering if the behavior is related

zbirenbaum commented 2 years ago

Yeah something changed, maybe its upstream, let me make a fix and try afterwards.

kozer commented 2 years ago

@zbirenbaum I think is because of this:

M.buf_attach_copilot = function()
  if vim.tbl_contains(M.params.ft_disable, vim.bo.filetype) then return end
  if not vim.bo.buflisted or not vim.bo.buftype == "" then return end
  local client_id = require("copilot.util").find_copilot_client()
  local buf_clients = vim.lsp.buf_get_clients(0)
  if client_id and buf_clients and not buf_clients[client_id] then
    vim.lsp.buf_attach_client(0, client_id)
  end
end
 local buf_clients = vim.lsp.buf_get_clients(0)

should return copilot. Copilot is there but not yet attached. So most probably buf_clients[client_id] is true

zbirenbaum commented 2 years ago

@zbirenbaum I think is because of this:

M.buf_attach_copilot = function()
  if vim.tbl_contains(M.params.ft_disable, vim.bo.filetype) then return end
  if not vim.bo.buflisted or not vim.bo.buftype == "" then return end
  local client_id = require("copilot.util").find_copilot_client()
  local buf_clients = vim.lsp.buf_get_clients(0)
  if client_id and buf_clients and not buf_clients[client_id] then
    vim.lsp.buf_attach_client(0, client_id)
  end
end```

 ``` local buf_clients = vim.lsp.buf_get_clients(0)```
should return copilot. Copilot is there but not attached.
So most probably `buf_clients[client_id]` is true 

That may be another component, but I put a print statement inside of this callback and it functions on the first open, but no subsequent ones. I think that something is wrong here.

      if vim.fn.has("nvim-0.7") > 0 then
        vim.api.nvim_create_autocmd({  "BufEnter"  }, {
          callback = vim.schedule(function()
            print("bufenter")
            M.buf_attach_copilot()
          end),
          once = false,
        })
enzom-uy commented 2 years ago

@kozer that worked! Thanks!! My cmp is full of other stuff but as I begin to type something Copilot appears there, really thank you and @zbirenbaum!

Edit: should I close the issue as #12 says? The problem is solved now thanks to that autocmd but idk if you guys needs to keep this issue open since the problem is still there without the autocmd.

zbirenbaum commented 2 years ago

Fantastic! Thanks @kozer. The autocmd behavior is not acting as it should still, so I need to fix that, but glad its working in the meantime!

Edit, yeah so I think @kozer is right about that logic being wrong, but even setting the callback to literally just call buf_attach directly still doesn't work, so the behavior of nvim_create_autocmd must have changed because that definitely wasn't the case a day or two ago.

I think that conditional was added by a PR or as a response to an issue, so I need to still check for buf clients being nil, but I changed the conditional to this which should work once the root issue is solved:

if not buf_clients and client_id or (client_id and not buf_clients[client_id]) then

zbirenbaum commented 2 years ago

Nah keep this open until I address the core issue @enzom-uy, that workaround isn't an official fix. I'll close it automatically with a commit once I've addressed it.

If after that you still have issues without the workaround, reopen this and I'll take a second stab at it in the morning.

zbirenbaum commented 2 years ago

So it was working perfectly fine before and I have no clue what happened, but I seem to have fixed it let me know and reopen this if anything comes up.

enzom-uy commented 2 years ago

I checked after the update if now works installing it as when I opened the issue

  use {
    "zbirenbaum/copilot.lua",
    event = { "VimEnter" },
    config = function()
      vim.defer_fn(function()
        require("copilot").setup()
      end, 100)
    end,
  }

and Copilot doesn't appear in :LspInfo. Although it works if I call the plugin on startup and the autocmd is not needed anymore, idk if this behaviour is expected.

zbirenbaum commented 2 years ago

I checked after the update if now works installing it as when I opened the issue


  use {

    "zbirenbaum/copilot.lua",

    event = { "VimEnter" },

    config = function()

      vim.defer_fn(function()

        require("copilot").setup()

      end, 100)

    end,

  }

and Copilot doesn't appear in :LspInfo.

Although it works if I call the plugin on startup and the autocmd is not needed anymore, idk if this behaviour is expected.

Oh man, ok I'm reopening this. I have some stuff to do right now but I'll take care of it in an hour or two.

If you open a new buffer in a split and edit a second file will copilot attach to that one? I'm thinking you may be getting the "attach before fully started" behavior

enzom-uy commented 2 years ago

If you open a new buffer in a split and edit a second file will copilot attach to that one?

Unfortunately not

enzom-uy commented 2 years ago

I just tried removing the "function()" right after the "config = " and it worked. Changed from 100ms to 10000ms just to test it out and it attached to the buffer right after the 10 seconds.

use {
    "zbirenbaum/copilot.lua",
    event = { "VimEnter" },
    config = vim.defer_fn(function()
       require("copilot").setup()
    end, 10000)
}
zbirenbaum commented 2 years ago

I just tried removing the "function()" right after the "config = " and it worked. Changed from 100ms to 10000ms just to test it out and it attached to the buffer right after the 10 seconds.

Oh ok so I was right about why then. Do you have a really slow startup time? 100 should be more than enough with a fast config. I would try reducing it to around 500, if that doesn’t work double it and so on.

Would you mind sharing the output of nvim —startuptime startup.log \<whatever file you’ve been having the issue with>

another good way is to have it run on insert enter, like listed in the readme but you will have some delay between then and have copilot first start providing suggestions.

enzom-uy commented 2 years ago

Oh ok so I was right about why then. Do you have a really slow startup time? 100 should be more than enough with a fast config. I would try reducing it to around 500, if that doesn’t work double it and so on.

Yeah 100ms is perfect at least for me, I was delaying it to make sure that it was working. I don't notice any extra delay when I open nvim

Would you mind sharing the output of nvim —startuptime startup.log <whatever file you’ve been having the issue with>

I have to take a look at it and see how I can optimize it, but here it is:

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.007  000.007: --- NVIM STARTING ---
000.224  000.217: locale set
000.490  000.266: inits 1
000.500  000.010: window checked
000.541  000.040: parsing arguments
002.419  001.879: expanding arguments
002.432  000.013: inits 2
002.859  000.427: init highlight
002.861  000.001: waiting for UI
003.398  000.537: done waiting for UI
003.421  000.023: init screen for UI
003.440  000.019: init default mappings
003.462  000.022: init default autocommands
004.555  000.048  000.048: sourcing /usr/share/nvim/runtime/ftplugin.vim
004.770  000.029  000.029: sourcing /usr/share/nvim/runtime/indent.vim
004.830  000.010  000.010: sourcing /usr/share/nvim/archlinux.vim
004.833  000.030  000.020: sourcing /etc/xdg/nvim/sysinit.vim
014.767  003.000  003.000: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/gruvbox.nvim/colors/gruvbox.lua
017.140  001.706  001.706: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/gruvbox.nvim/colors/gruvbox.lua
055.012  050.157  045.450: sourcing /home/enzom/.config/nvim/init.lua
055.031  001.305: sourcing vimrc file(s)
055.363  000.025  000.025: sourcing /usr/share/nvim/runtime/filetype.lua
061.217  000.015  000.015: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/LuaSnip/ftdetect/snippets.vim
061.545  000.012  000.012: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/cooklang.vim
061.570  000.010  000.010: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/fusion.vim
061.596  000.013  000.013: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/gdresource.vim
061.620  000.012  000.012: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/gdscript.vim
061.643  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/glimmer.vim
061.665  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/glsl.vim
061.688  000.010  000.010: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/gowork.vim
061.716  000.016  000.016: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/graphql.vim
061.744  000.014  000.014: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/hack.vim
061.772  000.015  000.015: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/hcl.vim
061.794  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/heex.vim
061.817  000.011  000.011: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/hjson.vim
061.839  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/json5.vim
061.869  000.016  000.016: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/ledger.vim
061.893  000.010  000.010: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/nix.vim
061.915  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/prisma.vim
061.936  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/pug.vim
061.962  000.013  000.013: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/ql.vim
062.000  000.025  000.025: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/query.vim
062.026  000.012  000.012: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/surface.vim
062.049  000.009  000.009: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/teal.vim
062.072  000.011  000.011: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/tlaplus.vim
062.117  000.011  000.011: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/ftdetect/yang.vim
062.229  000.010  000.010: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-fugitive/ftdetect/fugitive.vim
062.340  000.011  000.011: sourcing /usr/share/vim/vimfiles/ftdetect/PKGBUILD.vim
062.373  000.022  000.022: sourcing /usr/share/vim/vimfiles/ftdetect/meson.vim
062.739  007.358  007.026: sourcing /usr/share/nvim/runtime/filetype.vim
063.046  000.070  000.070: sourcing /usr/share/nvim/runtime/syntax/synload.vim
063.123  000.328  000.258: sourcing /usr/share/nvim/runtime/syntax/syntax.vim
064.007  000.014  000.014: sourcing /usr/share/nvim/runtime/plugin/gzip.vim
064.031  000.010  000.010: sourcing /usr/share/nvim/runtime/plugin/health.vim
064.129  000.087  000.087: sourcing /usr/share/nvim/runtime/plugin/man.vim
064.156  000.013  000.013: sourcing /usr/share/nvim/runtime/plugin/matchit.vim
064.298  000.130  000.130: sourcing /usr/share/nvim/runtime/plugin/matchparen.vim
064.332  000.016  000.016: sourcing /usr/share/nvim/runtime/plugin/netrwPlugin.vim
064.466  000.009  000.009: sourcing /home/enzom/.local/share/nvim/rplugin.vim
064.472  000.122  000.113: sourcing /usr/share/nvim/runtime/plugin/rplugin.vim
064.576  000.092  000.092: sourcing /usr/share/nvim/runtime/plugin/shada.vim
064.609  000.011  000.011: sourcing /usr/share/nvim/runtime/plugin/spellfile.vim
064.635  000.013  000.013: sourcing /usr/share/nvim/runtime/plugin/tarPlugin.vim
064.658  000.009  000.009: sourcing /usr/share/nvim/runtime/plugin/tohtml.vim
064.687  000.016  000.016: sourcing /usr/share/nvim/runtime/plugin/tutor.vim
064.714  000.014  000.014: sourcing /usr/share/nvim/runtime/plugin/zipPlugin.vim
065.286  000.510  000.510: sourcing /usr/share/vim/vimfiles/plugin/fzf.vim
065.501  001.700: loading rtp plugins
066.142  000.219  000.219: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/LuaSnip/plugin/luasnip.vim
066.407  000.056  000.056: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/harpoon/plugin/mark.vim
066.907  000.389  000.389: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim/plugin/indent_blankline.vim
067.343  000.330  000.330: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/kommentary/plugin/kommentary.vim
067.579  000.118  000.118: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/lspsaga.nvim/plugin/lspsaga.vim
067.865  000.154  000.154: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/markdown-preview.nvim/plugin/mkdp.vim
068.578  000.522  000.522: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-cmp/plugin/cmp.lua
068.691  000.035  000.035: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua/plugin/colorizer.vim
068.878  000.090  000.090: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer/plugin/nvim-lsp-installer.vim
069.051  000.076  000.076: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-lspconfig/plugin/lspconfig.vim
069.186  000.042  000.042: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-lsputils/plugin/nvim-lsputils.vim
069.285  000.011  000.011: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-smartbufs/plugin/nvim-smartbufs.vim
069.832  000.440  000.440: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-treesitter/plugin/nvim-treesitter.vim
070.166  000.218  000.218: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-ts-autotag/plugin/nvim-ts-autotag.vim
070.302  000.038  000.038: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/nvim-web-devicons/plugin/nvim-web-devicons.vim
070.429  000.038  000.038: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/plenary.nvim/plugin/plenary.vim
070.550  000.033  000.033: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/popfix/plugin/popfix.vim
070.870  000.169  000.169: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/telescope.nvim/plugin/telescope.vim
071.051  000.065  000.065: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/toggleterm.nvim/plugin/toggleterm.vim
071.285  000.123  000.123: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/undotree/plugin/undotree.vim
072.526  001.154  001.154: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-fugitive/plugin/fugitive.vim
072.903  000.270  000.270: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-move/plugin/move.vim
073.339  000.326  000.326: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-surround/plugin/surround.vim
075.669  000.251  000.251: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/vsnip.vim
076.013  000.080  000.080: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/LSP/Position.vim
076.213  000.024  000.024: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip.vim
076.500  001.254  000.900: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vsnip/snippet.vim
076.849  000.103  000.103: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/LSP/TextEdit.vim
077.189  000.048  000.048: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/LSP/Text.vim
077.600  000.092  000.092: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/Vim/Buffer.vim
077.973  000.043  000.043: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/Vim/Option.vim
078.430  000.114  000.114: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vital/_vsnip/VS/LSP/Diff.vim
078.598  003.522  001.868: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vsnip/session.vim
078.770  003.866  000.344: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/autoload/vsnip.vim
079.124  005.682  001.816: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip/plugin/vsnip.vim
079.313  000.077  000.077: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip-integ/plugin/vsnip_integ.vim
079.973  000.290  000.290: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vimwiki/autoload/vimwiki/vars.vim
081.124  000.083  000.083: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vimwiki/autoload/vimwiki/u.vim
083.144  003.739  003.366: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vimwiki/plugin/vimwiki.vim
083.274  003.359: loading packages
083.613  000.022  000.022: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip-integ/autoload/vsnip_integ/integration.vim
083.846  000.042  000.042: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip-integ/autoload/vsnip_integ/detection.vim
084.703  001.302  001.238: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/vim-vsnip-integ/after/plugin/vsnip_integ.vim
084.865  000.097  000.097: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua
085.033  000.110  000.110: sourcing /home/enzom/.local/share/nvim/site/pack/packer/start/cmp-tabnine/after/plugin/cmp-tabnine.lua
085.083  000.300: loading after plugins
085.096  000.014: inits 3
087.479  002.382: reading ShaDa
094.869  000.056  000.056: sourcing /usr/share/nvim/runtime/ftplugin/typescript.vim
094.928  000.300  000.243: sourcing /usr/share/nvim/runtime/ftplugin/typescriptreact.vim
107.543  003.918  003.918: sourcing /usr/share/nvim/runtime/syntax/typescriptcommon.vim
107.583  004.224  000.307: sourcing /usr/share/nvim/runtime/syntax/typescriptreact.vim
229.464  137.462: opening buffers
230.896  001.432: BufEnter autocommands
230.904  000.008: editing files in windows
231.773  000.869: VimEnter autocommands
231.781  000.008: UIEnter autocommands
232.282  000.279  000.279: sourcing /usr/share/nvim/runtime/autoload/provider/clipboard.vim
232.308  000.248: before starting main loop
339.356  107.048: first screen update
339.361  000.005: --- NVIM STARTED ---
zbirenbaum commented 2 years ago

I'm glad you got it working! I'll go ahead and close this since its all figured out, but holy cow dude that log could be an issue in itself! 😆

My 5 year old laptop which needed linux on it to even run because just starting windows was too much for it has a startup time of 45ms, and that's on massive files which trigger my lsp to start. You might want to look into using some lazy loading features from packer and moving over some of your plugin functionality to lua. I have a ton of plugins, but there are a few tricks which can make almost anything have virtually no impact whatsoever. I'm pretty good at it, so let me know if you want me to take a look at it some time.

If you don't have these three vars set to whatever the equivalent is on your system, they can make a massive difference in the order of hundreds of ms as well:

vim.g.python_host_skip_check = 1
vim.g.python3_host_prog = "/home/zach/.virtualenvs/py3nvim/bin/python"
vim.g.python_host_prog = "/home/zach/.virtualenvs/py2nvim/bin/python"