Skip to content
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

Possible to config custom get_trigger_characters for each source? #501

Closed
sandangel opened this issue Nov 9, 2021 · 4 comments
Closed
Labels

Comments

@sandangel
Copy link

sandangel commented Nov 9, 2021

I have the fuzzy_path source which has trigger characters as ., /, ~. I only want it is triggered on /, I tried to config with completion = { get_trigger_characters: ... }, but that is for all completion sources and will be overwritten by each source. Is there a way to do it for each complete source?

@hrsh7th
Copy link
Owner

hrsh7th commented Nov 9, 2021

Yes. Currently, nvim-cmp does not suppor this.

PR welcome :)

@sandangel
Copy link
Author

sandangel commented Nov 10, 2021

I think I found a workaround. I overwrite the function before calling cmp.setup. I think this will work because lua will cache the module, and the source registering happens after we loaded all plugins

local cmp_path = require 'cmp_path'

cmp_path.get_trigger_characters = function()
  return { '/' }
end

cmp.setup { }

😅

@hrsh7th
Copy link
Owner

hrsh7th commented Nov 23, 2021

I've added the cmp.setup { sources = { { name = " ... ", trigger_characters = { '.' } } } }

@hrsh7th hrsh7th closed this as completed Nov 23, 2021
@sandangel
Copy link
Author

awesome. thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants