Nvim-cmp: custom source get_keyword_pattern vs get_trigger_character

I’m working on creating a custom completion source and I don’t understand the difference between the source get_keyword_pattern and get_trigger_character functions. The documentation for these functions is particularly limited.

For context, I’m working on a cmp source that only suggests items when “b/” is typed. Setting the keyword_pattern to ‘b’ and the trigger character to ‘/’ seems to work, but the source:complete function gets called every time ‘b’ is typed. Ideally, this function would only be called when ‘b/’ is typed.

I appreciate the help! Thanks!

Setting the keyword pattern to ‘b/’ and not specifying the trigger characters has the desired effect of only invoking source:complete when ‘b/’ is typed, but the autocomplete menu is not brought up, so this is still not working.

Figured it out! Setting the pattern to ‘b/’ and omitting the trigger character works. The key was to have the response item labels begin with ‘b/’.