configGenerator top-level property

FigGenerator configGenerator
final

Implementation

final FigGenerator configGenerator = FigGenerator(
  trigger: '=',
  getQueryTerm: '=',
  custom: (tokens, execute, context) async {
    final lastToken = tokens.isNotEmpty ? tokens.last : '';
    if (!lastToken.contains('=')) {
      // Suggest keys
      return configPairs.entries
          .map((entry) => FigSuggestion(
                name: '${entry.key}=',
                description: entry.value.description,
              ))
          .toList();
    } else {
      // Suggest values
      final key = lastToken.split('=')[0];
      final pair = configPairs[key];
      if (pair?.tomlSuggestions != null) {
        return pair!.tomlSuggestions!;
      }
      return [];
    }
  },
);