8000 Support autocomplete for Ace editor by Roba1993 · Pull Request #714 · rune-rs/rune · GitHub
[go: up one dir, main page]

Skip to content

Support autocomplete for Ace editor #714

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

Merged
merged 8 commits into from
Aug 6, 2024
Merged

Conversation

Roba1993
Copy link
Contributor
@Roba1993 Roba1993 commented Jun 18, 2024

This PR adds the support for generating autocomplete instructions for the ace editor.
Refers to this feature request: #640

One topic is to detect std imports, which are available globally, like std::vec::Vec towards Vec.

Generate the autocomplete with the following rune cli command:

rune ace --output your/location/folder --extensions

The optional output parameter defines a different folder where the autocomplete.js file will be created.
The extensions flag will add a ? to all Option/Result returning functions and a .await to all async functions.

How to use this within your ace setup:

// ensure to register this ace file as dependency
//<script src="../build/src-noconflict/ext-language_tools.js"></script>

// import the generated autocomplete.js
import runeCompleter from "rune-ace/autocomplete";

// setup your ace editor as normal
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");

// enable autocompletion and optional snippets
editor.setOptions({
  enableBasicAutocompletion: true,
  //enableSnippets: true,
  enableLiveAutocompletion: true
});

// register the rune autocomplete
let langTools = ace.require("ace/ext/language_tools");
langTools.addCompleter(runeCompleter);

@udoprog
Copy link
Collaborator
udoprog commented Jun 19, 2024

Very neat! Could you include an example how this is used in the PR description?

@udoprog udoprog added the enhancement New feature or request label Jun 19, 2024
@Roba1993
Copy link
Contributor Author
Roba1993 commented Aug 3, 2024

Is there anything still to do, so that we can merge this PR?

@udoprog
Copy link
Collaborator
udoprog commented Aug 3, 2024

I don't think there's any outstanding issues, I'll rebase it once I'm done with the fmt refactoring.

@udoprog
Copy link
Collaborator
udoprog commented Aug 6, 2024

I've rebased this and updated the PR to work with the latest upstream. I'm working on including a local example so I can try it out, then I'll merge it.

@udoprog udoprog merged commit e36fcc3 into rune-rs:main Aug 6, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0