CM5: Dynamically add keywords to instantiated mode

Hi!

I’m trying to figure out what would be the best way to add new keywords to the instantiated mode based on the context. Specifically I’m using custom sql mode, and I’d like to add field names as tokens, but only those belonging to tables which are already added in editor - so every time there’s a new table name added, I’d like to add to the mode list of fields for this table (due to performance reason I don’t want to load all fields upfront, there are tens of thousands, and most are never used).

Thank You!
Maciej