From d01e8adbde12c9fe25a81fedbdac5d850072329d Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Thu, 13 Sep 2012 22:00:47 -0600 Subject: [PATCH] better scala indentation for case, self-types, etc --HG-- branch : pmacs2 --- mode/scala.py | 53 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/mode/scala.py b/mode/scala.py index 0a79e11..74929de 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -43,28 +43,45 @@ class ScalaGrammar(Grammar): RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'), RegionRule('scala.script', r'#!.+$', ShGrammar, r'!#'), + # determine types based on context PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)([a-zA-Z0-9_]+)', 'delimiter', 'scala.type'), PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)', 'delimiter', 'spaces', 'scala.type'), + PatternMatchRule('x', r'(?<=[^a-zA-Z0-9_])(new|extends|with)( +)([^0-9:\[\( ][^:\[\( ]*)', + 'scala.reserved', 'spaces', 'scala.type'), - PatternRule('scala.def', '(?<=(?|:|/|\+|-|\*|=)'), + # method names + PatternMatchRule('x', r'(?|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'), + + # semi-hack to support XML RegionRule('scala.inline', r'(?:^| )(?=<[a-zA-Z_])', XMLGrammar, '^[ \t]*$'), PatternRule('spaces', r'(?:\t| )+'), PatternRule('eol', r'\n'), - PatternRule('scala.class', '(?<=(?