Skip to content

Commit

Permalink
Added rec and mdo keyword to grammar
Browse files Browse the repository at this point in the history
Added automatic indent after `mdo`

Fixes #29
  • Loading branch information
JustusAdam committed Jun 27, 2017
1 parent 085da24 commit 7f69a75
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function activate(context: vscode.ExtensionContext) {

indentationRules: {
// ^.*\{[^}"']*$
increaseIndentPattern: /((\b(if\b.*|then|else|do|of|let|in|where))|=|->|>>=|>=>|=<<|(^(data)( |\t)+(\w|')+( |\t)*))( |\t)*$/,
increaseIndentPattern: /((\b(if\b.*|then|else|m?do|of|let|in|where))|=|->|>>=|>=>|=<<|(^(data)( |\t)+(\w|')+( |\t)*))( |\t)*$/,
decreaseIndentPattern: null
},
wordPattern: /([\w'_][\w'_\d]*)|([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)/
Expand Down
5 changes: 2 additions & 3 deletions syntaxes/haskell.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,10 @@
( deriving
| where
| type([\t ]+(family|role))
| case
| of
| let
| in
| default
| rec
)(\b(?!'))
</string>
<key>name</key>
Expand All @@ -334,7 +333,7 @@
</dict>
<dict>
<key>match</key>
<string>\b(do|if|then|else)(\b(?!'))</string>
<string>\b(m?do|if|then|else|case|of)(\b(?!'))</string>
<key>name</key>
<string>keyword.control.haskell</string>
</dict>
Expand Down
9 changes: 9 additions & 0 deletions test.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RecursiveDo #-}
module Main where

import Data.Version as V (Version(..))
Expand Down Expand Up @@ -36,6 +37,14 @@ someFunc = do
ident' = 9


recDo = mdo
a <- b
return b

explicitRecDo = do
a <- rec { c <- d }
return a

anotherFunc :: MyData -> Int
anotherFunc arg =
let something = "hello" :: String in expression
Expand Down

0 comments on commit 7f69a75

Please sign in to comment.