I am working on a language extension for SAS for VScode. I previously worked on the SAS language extension for Atom (https://github.com/akanosora/language-sas) as well as Vi
You can add the data
and proc
keywords themselves to the "decreaseIndentPattern"
rule. This way, these keywords will serve for both un-indenting the current line, and starting a new indentation block on the next line.
Consider this, for example:
"indentationRules": {
"increaseIndentPattern": "^\\s*(proc|data)\\s+.*;\\s*$",
"decreaseIndentPattern": "^\\s*(run|((proc|data)\\s+.*))\\s*;"
}
For more advanced indentation, you could look into using a formatter alongside the regular expression based indentation rules. To add a custom formatter, your extension should implement DocumentRangeFormattingEditProvider and then register the with VS Code by calling registerDocumentRangeFormattingEditProvider
Formatters must normally be invoked by the user. However users can also enable formatting as they type by setting "editor.formatOnType": true
. For this case, your extension should also implement OnTypeFormattingEditProvider and register the on-type formatter by calling registerOnTypeFormattingEditProvider