Generic functions to support custom insert mode completions.