atom-haskell / ide-haskell-repl

GHCi REPL in Atom
https://atom.io/packages/ide-haskell-repl
MIT License
26 stars 8 forks source link

Basic autocomplete #45

Closed yaeti closed 7 years ago

yaeti commented 7 years ago

I implemented simple tab-completion for the REPL. I also changed font used in output area to monospace.

lierdakil commented 7 years ago

Thank you very much for this work.

However, I think we could leverage autocomplete-plus after all here.

I was digging around and found out that there is (currently undocumented) feature in autocomplete-plus, which works at least since Atom 1.12.8, and allows for some additional provider customization. In particular, we can specify CSS selector which text editor has to satisfy.

Long story short, something along the lines of

  "providedServices": {
    "autocomplete.provider": {
      "versions": {
        "3.0.0": "autocompleteProvider_3_0_0"
      }
    }
  }

in package.json and

  autocompleteProvider_3_0_0: ->
    scopeSelector: '.source.haskell'
    disableForScopeSelector: '.source.haskell .comment'
    getTextEditorSelector: ->
      'atom-text-editor.ide-haskell-repl'
    inclusionPriority: 0
    getSuggestions: (options) ->
      # build suggestions here

will enable an autocomplete-plus provider on ide-haskell-repl input.

I would also suggest using fuzzaldrin for filtering/sorting the suggestion list, instead of relying on GHCi, i.e. get all identifiers with :complete repl "" and then filter those out based on prefix. Reason being, this should work reasonably well with abbreviations and typos, while GHCi's way of doing things won't.

What do you think?

yaeti commented 7 years ago

Thank you very much for your suggestions. Leveraging autocomplete-plus looks very promising. I also like the idea of typo-proofing completions by filtering them ourselves. I will definitely look into this.

yaeti commented 7 years ago

I've made a few changes: switched to autocomplete-plus and used fuzzaldrin to filter the completions from GHCi.

yaeti commented 7 years ago

Thank you very much for your valuable suggestions! I fixed these problems.

lierdakil commented 7 years ago

Okay, merged and released as 0.5.0 :tada: