-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Closed
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiderson-testplan
Milestone
Description
Currently, onEnterRules can only be defined imperatively, via vscode.languages.setLanguageConfiguration. Most of the other language configuration properties can already today be defined descriptively, in the language configuration file (contributes.languages.configuration).
It would make sense to allow onEnterRules to be defined in the language configuration file to align with the other properties.
The only problematic thing is the schema for such rules because in the imperative version an enum is used, IndentAction and it might make sense to use a string value with the enum name in JSON.
For example (imperative variant):
vscode.languages.setLanguageConfiguration('python', {
onEnterRules: [
{
beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,
action: { indentAction: vscode.IndentAction.Indent }
}
]
});language-configuration.json proposal:
{
"onEnterRules": [
{
"beforeText": "^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$",
// regexes can also explicitly define flags with this format: { "pattern": "...", "flags": "iu" }
// "afterText": "", // optional regex for the text after the cursor on the current line
// "oneLineAboveText": "", // optional regex for the text one line above
"action": {
"indent": "indent", // other values "none","indent", "indentoutdent", "outdent"
"appendText": "", // optional text to be appended after the enter
"removeText": 0 // optional char count to delete
}
}
]
}cc @dbaeumer
uniqueiniquity, olegtk and veler
Metadata
Metadata
Assignees
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiderson-testplan