This plugin must be loaded after cmp to make options work
AFAIK a lot of people use cmp-tmux as a dependency of cmp for convenience. As a result, option set during cmp setup won't effect the source.config which have already been created during cmp-tmux setup.
Please consider using lazy-initialization instead or at least mention this unexpected behaviour in README.
mention this unexpected behaviour
Sorry, but I don't completely understand what you mean here. From what I can tell cmp-tmux registers itself just like other extensions for cmp.
Care to elaborate on this?
Thank you for your prompt attention to my issue.
In lua/cmp_tmux/source.lua,
local config = require('cmp.config')
requires cmp.setup to be called or you won't get anything valuable.
However, people like me may get used to write configures like
-- lazy.nvim
return {
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
...
"andersevenrud/cmp-tmux",
...
},
name = "cmp",
config = function()
...
local cmp = require("cmp")
...
cmp.setup({
...
sources = {
...
{
name = "tmux",
option = {
label = "",
trigger_characters = {},
},
},
...
},
...
})
...
end,
},
}
where cmp.tmux config will be loaded before that setup.
I have spotted a few other issues (like #27) that could be for the same reason.
Aha! I actually use pretty much the same setup as you, but actually haven't noticed this!
I'm a little bit busy at the moment, so if you have something in mind that could solve this feel free to open a pull-request.
Actually I have found a workaround for this issue by not using option provided by your plugin:
- using
{ name = "tmux", keyword_length = 2, trigger_characters = {} }to configure trigger rules. - using
lspkind.cmp_format({ before = function()...to remove that label.
But I'm still interested in improving your plugin. There should be 2 approaches:
- lazy-initializing
source - adding a setup stage like uga-rosa/cmp-dictionary
I would suggest remove all redundant options which have already been provided by cmp and move the others into a setup stage.