'use babel';

import completions from '../data/completions';

class CurryProvider {
  constructor() {
    this.scopeSelector = '.source.curry';
    this.disableForScopeSelector = '.source.curry .comment';

    this.suggestionPriority = 2;
    this.filterSuggestions = true;

    this.acpTypes = new Map([['types', 'type'], ['constructors', 'tag'], ['functions', 'function']]);
  }

  getSuggestions({prefix}) {
    const suggestions = [];

    if (prefix) {
      for (const module of completions) {
        for (const [key, type] of this.acpTypes) {
          const createSugg = this.createSuggestion.bind(null, module.name, type);

          const matches = module[key].map(createSugg);

          suggestions.push(...matches);
        }
      }
    }

    return suggestions;
  }

  createSuggestion(module, type, suggestion) {
    return {
      text: suggestion.name,
      description: suggestion.description,
      type: type,
      leftLabel: module,
      rightLabel: suggestion.typeSig
    };
  }
}

export default new CurryProvider();
'use babel';

import completions from '../data/completions';

class CurryProvider {
  constructor() {
    this.scopeSelector = '.source.curry';
    this.disableForScopeSelector = '.source.curry .comment';

    this.suggestionPriority = 2;
    this.filterSuggestions = true;

    this.acpTypes = new Map([['types', 'type'], ['constructors', 'tag'], ['functions', 'function']]);
  }

  getSuggestions({prefix}) {
    if (prefix) {
      const suggestions = [];

      for (const module of completions) {
        for (const [key, type] of this.acpTypes) {
          const createSugg = this.createSuggestion.bind(null, module.name, type);

          const matches = module[key].map(createSugg);

          suggestions.push(...matches);
        }
      }

      return suggestions;
    }

    return null;
  }

  createSuggestion(module, type, suggestion) {
    return {
      text: suggestion.name,
      description: suggestion.description,
      type: type,
      leftLabel: module,
      rightLabel: suggestion.typeSig
    };
  }
}

export default new CurryProvider();
Return null if the prefix is not valid
Return null if the prefix is not valid
