Question

I've been doing a lot of MaxScript lately and have mashed together (from an attempt here) a ST2 plugin for evaluating scripts from ST.

I've got the syntax highlighting working as well as evaluating the whole file and the current selection, but what I need (due partly to my bad memory and also the gigantic number of MaxScript built-in functions, not to mention those exposed by other plugins I'm using) is for the autocomplete list to be populated initially by a separate text file containing the built-in function names (generated by these instructions) and then the file's own names.

The text file is of the following format:

...
<function name>
polyOps.createShapeFromEdges
polyOps.startCutEdge
polyOps.selectByID
polyOps.attachList
polyOps.startExtrudeEdge
...

Can anyone give me any pointers?

Was it helpful?

Solution

The completions docs have all the information you'll need. Briefly, .sublime-completions files are JSON-formatted resources that can contain either simple completions or snippets. For example, a simple completions list using your given terms would look like this:

{
    "scope": "source.maxscript",

    "completions": [

        "polyOps.createShapeFromEdges",
        "polyOps.startCutEdge",
        "polyOps.selectByID",
        "polyOps.attachList",
        "polyOps.startExtrudeEdge"
    ]
}

If you would like to use snippet syntax for more complex auto-completion (for example, to fill in default values for a function), it would look something like this:

{
    "scope": "source.maxscript",

    "completions": [

        { "trigger": "myfunc", "contents": "my_function(${1:param}=${2:value})$0" },

        "polyOps.createShapeFromEdges",
        "polyOps.startCutEdge",
        "polyOps.selectByID",
        "polyOps.attachList",
        "polyOps.startExtrudeEdge"
    ]
}

Once you have your completions set up, save the file as Packages/User/LanguageName.sublime-completions where LanguageName is the name of your .tmLanguage file, and you should be all set. Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top