azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
210 stars 12 forks source link

Proposing snippets #14

Closed GulnazSerikbay closed 1 year ago

GulnazSerikbay commented 1 year ago

Problem

I love this extension! Not really a problem, but I could suggest new snippets that I find convenient, especially for 15-150 students.

TODO

Solution

Adding these to json file with snippets: "While": { "prefix": ["while", "while do"], "body": [ "while ${1:exp1} do ${2:exp2} " ], "description": "A while loop." }, "Function Contracts": { "prefix": ["function contract", "contracts", "requires", "ensures"], "body": [ "( ", " ${1:functionName}: ${2:inputType} -> ${3:outputType}", " REQUIRES: ", " ENSURES: ", " *)" ], "description":"A comment block for function contracts." }, "Print statement": { "prefix": "print", "body": [ "val _ = print(${1:})" ], "description":"A print statement" },

TODO Change json file containing snippets

azdavis commented 1 year ago

I think the print one makes sense, especially since SML's print doesn't add a newline by default, a frequent annoyance. I'll add a snippet for printing with a newline.

While loops are somewhat avoided; I've never seen them used, so I wouldn't even know what the style should be for the snippet code. Plus, the "snippet" really only gives you two tokens: while and do. Those are easy enough to type.

The function contract comment is 15-150 specific, and I'd rather not have too much (or really, anything) specific to any certain course in Millet. There is the for 15-150 doc, but I'd like to eventually get rid of it if and when Millet gets 'official' 15-150 support.

Also, in general, I'd rather not have too many snippets.

You can add your own snippets as user-specific snippets.