Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33 from masad-frost/fm-py-indent
Browse files Browse the repository at this point in the history
Add auto-indentation for python
  • Loading branch information
alexdima authored May 29, 2018
2 parents 781bcdd + 5c84804 commit c09fd5d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage;

// Allow for running under nodejs/requirejs in tests
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);

export const conf: IRichLanguageConfiguration = {
comments: {
lineComment: '#',
Expand All @@ -32,6 +35,12 @@ export const conf: IRichLanguageConfiguration = {
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
],
onEnterRules: [
{
beforeText: new RegExp("^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$"),
action: { indentAction: _monaco.languages.IndentAction.Indent }
}
],
folding: {
offSide: true,
markers: {
Expand Down

0 comments on commit c09fd5d

Please sign in to comment.