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
![image](https://private-user-images.githubusercontent.com/59988195/322216924-b61bf120-bf7d-4c10-9eca-d5ab1e1e32f5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4MTAxNDQsIm5iZiI6MTcyMTgwOTg0NCwicGF0aCI6Ii81OTk4ODE5NS8zMjIyMTY5MjQtYjYxYmYxMjAtYmY3ZC00YzEwLTllY2EtZDVhYjFlMWUzMmY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFF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PTAmcmVwb19pZD0wIn0.FC-nGAjd01ft7gObRiMfFFYbQerIaevrZWyx_lxik34)
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