Replies: 1 comment
-
After some more research I found #1197 (comment) which implies I attempted another approach, instead of injecting the source into For example input vim.api.nvim_create_user_command("FzfLua", function(opts)
require("fzf-lua.cmd").run_command(unpack(opts.fargs))
end, {
nargs = "*",
range = true,
complete = function(_, line)
print("called", #line, line, line:match("%s+$") ~= nil)
}) The However, after calling vim.api.nvim_create_user_command("FzfLua", function(opts)
require("fzf-lua.cmd").run_command(unpack(opts.fargs))
end, {
nargs = "*",
range = true,
complete = function(_, line)
-- without calling `cmp.complete` this gets called right after
print("called", #line, line, line:match("%s+$") ~= nil)
vim.schedule(function()
require("cmp").complete({
config = {
sources = {
{ name = "FzfLua" }
}
}
})
end)
end,
}) @hrsh7th, is this by design or is this a bug? |
Beta Was this translation helpful? Give feedback.
-
Hi @hrsh7th and ty for your wonderful work.
For context, WIP code for my custom nvim-cmp source can be found at https://github.com/ibhagwan/fzf-lua/blob/cmp_src/lua/fzf-lua/cmp_src.lua.
What I'm currently trying to achieve is the following:
FzfLua ...
vianvim_create_user_command.complete
Once registered, I am able to display docs via the
Source:resolve
callback (thus providing documentaiton for commands/options).I have a couple of quesions:
Is the above the correct way of injecting a registered source to the commad line completion module?
My custom source is only called after I start typing a single letter due to my config setting
completion.keyword_lengh=1
but that causes an issue where my docs aren't displayed on the initial completion, for example, after typing:FzfLua <space>
the nvim-cmp source appears as[Cmdline]
and the docs aren't being resolved:After typing
:FzfLua f
, my source is being called (note the source name[FzfLua]
) and I see the docs:Is there a better way to write a completion source that can generate docs for a user command regardless of the
keyword_length
setting?Beta Was this translation helpful? Give feedback.
All reactions