<commit_before># Implements Slime autocompletion!

module.exports =
  selector: '.source.lisp-repl, .source.lisp'
  disableForSelector: '.comment'
  disabled: false

  # This will take priority over the default provider, which has a priority of 0.
  # `excludeLowerPriority` will suppress any providers with a lower priority
  # i.e. The default provider will be suppressed
  inclusionPriority: 1
  excludeLowerPriority: true

  # Required: Return a promise, an array of suggestions, or null.
  getSuggestions: ({editor, bufferPosition, scopeDescriptor, prefix}) ->
    if @swank?.connected and !@disabled and prefix != ""
      return @swank.autocomplete(prefix, @repl.pkg).then (acs) =>
        return (text:ac for ac in acs)
    else
      return new Promise (resolve) ->
        resolve([])

  # (optional): called _after_ the suggestion `replacementPrefix` is replaced
  # by the suggestion `text` in the buffer
  onDidInsertSuggestion: ({editor, triggerPosition, suggestion}) ->

  # (optional): called when your provider needs to be cleaned up. Unsubscribe
  # from things, kill any processes, etc.
  dispose: ->

  setup: (@swank, @repl) ->

  disable: () -> @disabled = true
  enable: () -> @disabled = false<commit_msg>Better autocomplete prefix provider!<commit_after># Implements Slime autocompletion!
utils = require './utils'

module.exports =
  selector: '.source.lisp-repl, .source.lisp'
  disableForSelector: '.comment'
  disabled: false

  # This will take priority over the default provider, which has a priority of 0.
  # `excludeLowerPriority` will suppress any providers with a lower priority
  # i.e. The default provider will be suppressed
  inclusionPriority: 1
  excludeLowerPriority: true

  # Required: Return a promise, an array of suggestions, or null.
  getSuggestions: ({editor, bufferPosition}) ->
    prefix = @getPrefix(editor, bufferPosition)
    console.log prefix
    if @swank?.connected and !@disabled and prefix != ""
      return @swank.autocomplete(prefix, @repl.pkg).then (acs) =>
        return ({text: ac, replacementPrefix: prefix} for ac in acs)
    else
      return new Promise (resolve) ->
        resolve([])


  # A better prefix for Lisp
  getPrefix: (editor, bufferPosition) ->
    # Get the text for the line up to the triggered buffer position
    line = editor.getTextInRange([[bufferPosition.row, @repl.prompt.length], bufferPosition])
    # Match the regex to the line, and return the match
    matches = line.match(utils.lispWordRegex)
    console.log matches
    return matches?[matches?.length - 1] or ''

  # (optional): called _after_ the suggestion `replacementPrefix` is replaced
  # by the suggestion `text` in the buffer
  onDidInsertSuggestion: ({editor, triggerPosition, suggestion}) ->

  # (optional): called when your provider needs to be cleaned up. Unsubscribe
  # from things, kill any processes, etc.
  dispose: ->

  setup: (@swank, @repl) ->

  disable: () -> @disabled = true
  enable: () -> @disabled = false
{'fraction_non_alphanumeric': 0.10501672240802676, 'fraction_numerical': 0.0016722408026755853, 'mean_word_length': 3.7627388535031847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7531515', 'n_tokens_mistral': 853, 'n_tokens_neox': 822, 'n_words': 311}