micangl / cmp-vimtex

Vimtex source for nvim-cmp.
MIT License
72 stars 5 forks source link

duplicated vimtex source problem #22

Open Jaehaks opened 2 months ago

Jaehaks commented 2 months ago

Thank you for your efforts,

If I configure cmp-vimex, CmpStatus shows me the vimtex sources are duplicated In nvim-cmp lazy.nvim setup, I called the cmp-vimtex plugin as dependencies.

Case 1) If I don't configure cmp-vimtex

dependencies = {
  'hrsh7th/cmp-buffer',       -- source for text in buffer
  'hrsh7th/cmp-path',         -- source for file system path
  'hrsh7th/cmp-cmdline',        -- source for commandline, [command], [path]
  'hrsh7th/cmp-nvim-lsp',     -- using LSP for source
  'f3fora/cmp-spell',           -- source for vim's spellsuggest
  'L3MON4D3/LuaSnip',         -- snippet engine
  'saadparwaiz1/cmp_luasnip', -- using LuaSnip for source
  'mstanciu552/cmp-matlab',   -- source of matlab
  {
    'micangl/cmp-vimtex',       -- source of vimtex for latex
  },
},

Cmp-vimtex loaded just once for unused source names (I didn't load this source to confirm how many this source is called just.) image

Case 2) If I configure cmp-vimtex

dependencies = {
  'hrsh7th/cmp-buffer',       -- source for text in buffer
  'hrsh7th/cmp-path',         -- source for file system path
  'hrsh7th/cmp-cmdline',        -- source for commandline, [command], [path]
  'hrsh7th/cmp-nvim-lsp',     -- using LSP for source
  'f3fora/cmp-spell',           -- source for vim's spellsuggest
  'L3MON4D3/LuaSnip',         -- snippet engine
  'saadparwaiz1/cmp_luasnip', -- using LuaSnip for source
  'mstanciu552/cmp-matlab',   -- source of matlab
  {
    'micangl/cmp-vimtex',       -- source of vimtex for latex
    config = function ()
      require('cmp_vimtex').setup({})
    end
  },
},

Cmp-vimtex loaded twice as below image

Could you know where the vimtex source are called one more?

micangl commented 2 months ago

Thanks for raising the issue! May I ask @benbrastmckie if he is seeing the same output (vimtex listed twice in CmpStatus), as I see that he has a similar configuration?

It shouldn't, in any case, interfere with anything.

Jaehaks commented 2 months ago

@micangl Sure, Of course. I checked the config repository of @benbrastmckie. He configured the cmp-vimtex like this,

1) configure cmp-vimtex in a file vimtex-cmp.lua separately and use lazy=false loading 2) use cmp-vimtex as dependencies of nvim-cmp without any configuration

I applied above configuraiton before and It worked fine because it only loads once and configuration can be applied. But The downside is that it makes nvim loading time longer than before because cmp-vimtex is loaded at startup always with long load time (~200ms)

I want to lazy-load cmp-vimtex when nvim-cmp is loaded. But If he set lazy true in vimtex-cmp.lua, the vimtex will be called twice as the same with what I said

micangl commented 2 months ago

@Jaehaks Unfortunately, there doesn't seem to be a way with lazy to call the setup function before the after/plugin/ files are sourced. This is what happens with the "normal" plugin loading process, and is necessary to keep the source compatible with non-lazy loaders.

At the moment I'm completely swamped so, since this is not a bug which prevents the plugin from working, I'll have to postpone finding a fix, as there doesn't seem to be an immediate one.