anyword hinting while in JavaScript mode

I am trying to get the anyword hinting to work along side the JavaScript hinting.

I have them both loaded, but I can’t seem to get them to function together. is there something special I must do?

You could write a wrapper function that calls both and combines the result, and set that as your hint function.

Can you help please, I have no idea how to do that, or where to even start.

How hard would it be to internally stack hint functions as they are defined?

Similar to how (which uses codemirror) has a hint manager that stacks hint functions. Similar to how codemirror does cm.on/ handling?

So if I had multiple hint functions for a language they would all run then merge the results. Then a [“all”] mode to have it run for all languages.

I think this would be a great addition to codemirror.

I’ve been struggling to get this to work, can you please help with an example please?

I am trying to have the anyword hint work on all modes, filtered in with the actual hint from the other modes.

I can not get this to work. I have looked at stack, here, tried solutions, but it maybe beyond me.

Please help. Thank you greatly.

Here’s what a wrapper might look like:

function hintingFunction(cm, options) {
  const anyhint = CodeMirror.hint.anyword(cm, options)
  const jshint = CodeMirror.hint.javascript(cm, options)
  const words = new Set([...anyhint.list, ...jshint.list])
  if (words.size > 0) {
    return {
      list: Array.from(words), 
      from: jshint.from, 

CodeMirror(document.body, {
  extraKeys: {
    'Ctrl-Space': (cm) => {
      cm.showHint({hint: hintingFunction})

If you need to filter them based on mode, you can register a helper that uses a predicate:

CodeMirror.registerGlobalHelper('hint', 'allhints',
  function(mode, cm) {
    // check if helper applies to mode...
    return true
  function(cm, options) {
    // filter hint functions...
    return [

Then use the helper in your hinting function:

const getHintFunctions = cm.getHelper(CodeMirror.Pos(0, 0), 'hint') 
for (const hint of getHintFunctions()) {
    const completion = hint(cm, options)
    // merge...
1 Like

@wormboy thank you very much, actually seeing the code made it easy to implement the way I needed .