diff --git a/mode/scala.py b/mode/scala.py index deff0b1..6519c22 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -1,5 +1,5 @@ #import commands -#from tab import StackTabber +from tab import StackTabber2 #from method import Method from mode import Fundamental from lex import Grammar, PatternRule, RegionRule, PatternMatchRule @@ -54,11 +54,25 @@ class ScalaGrammar(Grammar): PatternRule('scala.null', 'null'), ] +class ScalaTabber(StackTabber2): + open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} + close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} + control_tokens = {'scala.reserved': set(('if', 'else', 'while', 'do', 'for'))} + end_at_eof = True + start_free_tokens = {'string.start': 'string.end'} + end_free_tokens = {'string.end': 'string.start'} + is_ignored_tokens = set(('spaces', 'eol', 'comment', 'comment.start', + 'comment.data', 'comment.null', 'comment.end')) + is_indent_tokens = set(('spaces',)) + def is_base(self, y): return y == 0 + class Scala(Fundamental): name = 'Scala' extensions = ['.scala'] + tabwidth = 2 + tabbercls = ScalaTabber grammar = ScalaGrammar - commentc = '--' + commentc = '//' opentokens = ('delimiter',) opentags = {'(': ')', '[': ']', '{': '}'} closetokens = ('delimiter',) @@ -75,9 +89,9 @@ class Scala(Fundamental): } _bindings = { - 'close-paren': (')',), - 'close-brace': ('}',), - 'close-bracket': (']',), + 'close-paren': (')',), + 'close-brace': ('}',), + 'close-bracket': (']',), } def install(*args):