How can I make custom Autocomplete suggestions?

I’m making a small VR module and I want to add function to my plugin so that it will have a suggestion while you are Scripting. I’ve seen other plugins do this

Idk what the Autocomplete is actually called, example below

By Autocomplete, I mean this:
th-1318690930

You would need to store every Enum type in existance, and every instance type etc etc etc, then do autocomplete suggestions based off whats currently typed with seperators being “.” and “:”
you would take advantage of string.match and string.sub.

you would use string sub to make every stored autocomplete candidate (e.g objectvalue, numbervalue) match your current inputs length,
for example my input is “workspace.co” so itll look at “co” and thats string.len(2), so your going to string.sub objvalue and numvalue to get “ob” and “nu”, now your using string.match to get every possible candidate that matches obv with string.lower(), then you just need a hierarchy to reorder it so for example Instance Values would be above Services.

this is how you would achieve autocorrect, as for as fast method of storing every possible autocomplete suggestion in a table (getting them all) i dont know how to achieve that, getting every enum type would be easy, but getting every service etc there might be something in the api somewhere.

I would recommend looking into ScriptEditorService:RegisterAutocompleteCallback() for how to add custom auto completions, and also, if you want to see an autocomplete project done by someone else for some examples, then there is This Post Which has the source code for Baileyeatspizza’s Service Auto-Complete Plugin.

Also sorry about being a bit late.

1 Like