-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
user defined is_available
#632
Comments
Currently, I think I have to clean up the source configuration API. (But it's difficult.) |
What about passing plugin's original cmp.setup({
sources = {
{
name = 'rg',
is_available = function(original_is_available_fn, ...)
local is_in_git_tree = vim.trim(vim.fn.system('git rev-parse --is-inside-work-tree')) == 'true'
return is_in_git_tree and original_is_available_fn(...)
end,
}
}
}) ? This way the user gets to decide whether the source-defined |
sources = {
{
name = 'buffer',
override = {
get_keyword_pattern = function(source, ...)
return source:get_keyword_pattern(...)
end,
get_trigger_characters = function(source, ...)
return source:get_trigger_characters(...)
end,
complete = function(source, params, callback)
source:complete(params, function(response)
-- modify responses...
callback(response)
end)
end
}
} |
I think if we introduce this, we should deprecate the |
overwrite system makes sense to me 👍 It might be easier to maintain if it just works as a sort of constructor function? Instead of This way, users can do whatever they want to the source object. And you never have to touch this part again, even if you add more things to sources. sources = {
{
name = "buffer",
init = function(source)
-- I can do more stuff here.
return {
get_keyword_pattern = function(...)
return source:get_keyword_pattern(...)
end,
get_trigger_characters = function(...)
return source:get_trigger_characters(...)
end,
complete = function(params, callback)
source:complete(params, function(response)
-- modify responses...
callback(response)
end)
end,
}
end,
},
} |
sources can define the
is_available
function, but there is no way for users to do this.I think it would be nice to expose this to users as well. So sources don't have to build custom solutions for this.
I think it should not overwrite the source defined
is_available
. cmp should check both. If either one returnsfalse
, the source is not available.I can make a PR if you want this
The text was updated successfully, but these errors were encountered: