Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete #32

Open
paf31 opened this issue Nov 29, 2016 · 4 comments · May be fixed by #270
Open

Autocomplete #32

paf31 opened this issue Nov 29, 2016 · 4 comments · May be fixed by #270

Comments

@paf31
Copy link
Contributor

paf31 commented Nov 29, 2016

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

@thomashoneyman
Copy link
Member

thomashoneyman commented Nov 20, 2021

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
Copy link

nwolverson commented Nov 20, 2021

I know nothing about ace, but if (server side) you want to do completion, the language server is all driven by purs ide server (via purescript-psc-ide), including imports (see https://github.com/nwolverson/purescript-language-server/blob/78086f60f2741d5fe52bbad8572c107863091eb8/src/LanguageServer/IdePurescript/Completion.purs#L119 eventually ending at https://github.com/nwolverson/purescript-language-server/blob/78086f60f2741d5fe52bbad8572c107863091eb8/src/IdePurescript/Modules.purs#L191 ).

For reference look at the psc-ide protocol https://github.com/purescript/purescript/blob/master/psc-ide/PROTOCOL.md - complete and import sections.

@pete-murphy pete-murphy linked a pull request Feb 6, 2022 that will close this issue
4 tasks
@pete-murphy
Copy link
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
Copy link

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants