Skip to content

Autocomplete #32

Open
Open
@paf31

Description

@paf31
Contributor

Ace probably provides an API for this, we just need to expose it on the server.

Activity

thomashoneyman

thomashoneyman commented on Nov 20, 2021

@thomashoneyman
Member

Ace does provide support for autocompletion via the ace/ext/language_tools package. There's a wiki page with some admittedly sparse details:
https://github.com/ajaxorg/ace/wiki/How-to-enable-Autocomplete-in-the-Ace-editor

The wiki includes a link to a demo, however, which is useful for seeing how to implement your own autocompletion. We'd presumably want to do something similar, calling back to some PureScript code to provide the completions:
https://plnkr.co/edit/6MVntVmXYUbjR0DI82Cr?p=preview&preview

There is existing PureScript code written around autocompletions in this context, namely in the purescript-language-server package. From a glance through that package, this looks relevant (but I'd like to hear if @nwolverson has any suggestions for doing this in an Ace context):

https://github.com/nwolverson/purescript-language-server/blob/78086f60f2741d5fe52bbad8572c107863091eb8/src/IdePurescript/Completion.purs#L73-L84

Of course, then there's the second concern: once we have the autocomplete suggestion and the user selects it, then we have to actually update the imports properly in the editor; I'm not exactly sure where this is done in the language server.

nwolverson

nwolverson commented on Nov 20, 2021

@nwolverson
linked a pull request that will close this issue on Feb 6, 2022
pete-murphy

pete-murphy commented on Feb 6, 2022

@pete-murphy
Contributor

I started looking into this here but backend stuff isn't really my strong suit, and I have no idea if I'm going down the right path. Right now I'm starting up purs ide server along with server, and then running purs ide client on every request to a /complete endpoint. Does that sound about like the right approach as far as the backend implementation?

nwolverson

nwolverson commented on Feb 8, 2022

@nwolverson

@ptrfrncsmrph it's a little round-about, ultimately you might want to just make the socket connection directly, but it should do to get started. You might want to look at the purescript client bindings https://github.com/kritzcreek/purescript-psc-ide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @paf31@nwolverson@thomashoneyman@pete-murphy

      Issue actions

        Autocomplete · Issue #32 · purescript/trypurescript