parent
42fb1aebb5
commit
ef56ae12bc
|
@ -59,7 +59,19 @@ class JavascriptGrammar(Grammar):
|
|||
RegionRule('string', '"', StringGrammar2, '"'),
|
||||
]
|
||||
|
||||
class JavascriptTabber(tab.StackTabber):
|
||||
class JavascriptTabber2(tab.StackTabber2):
|
||||
open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
|
||||
close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
|
||||
control_tokens = {'keyword': {'if': 1, 'else': 1, 'while': 1, 'do': 1, 'for': 1}}
|
||||
end_at_eof = False
|
||||
end_at_tokens = {'delimiter': {';': 1}}
|
||||
nocontinue_tokens = {'delimiter': {';': 1},
|
||||
'comment': 1,
|
||||
'comment.start': 1,
|
||||
'comment.data': 1,
|
||||
'comment.end': 1}
|
||||
start_free_tokens = {'string.start': 'string.end'}
|
||||
end_free_tokens = {'string.end': 'string.start'}
|
||||
def is_base(self, y):
|
||||
if y == 0:
|
||||
return True
|
||||
|
@ -67,22 +79,18 @@ class JavascriptTabber(tab.StackTabber):
|
|||
if not highlighter.tokens[y]:
|
||||
return False
|
||||
t = highlighter.tokens[y][0]
|
||||
return t.name == 'reserved' and t.string == 'function'
|
||||
def _handle_other_token(self, currlvl, y, i):
|
||||
w = self.mode.tabwidth
|
||||
token = self.get_token(y, i)
|
||||
fqname = token.fqname()
|
||||
if token.name == 'operator' and token.string == '=':
|
||||
self._opt_append("cont", currlvl + w)
|
||||
elif token.name == 'delimiter' and token.string == ";":
|
||||
self._opt_pop("cont")
|
||||
return currlvl
|
||||
return t.name == 'js_reserved' and t.string == 'function'
|
||||
def _is_indent(self, t):
|
||||
return t.name == 'spaces'
|
||||
def _is_ignored(self, t):
|
||||
return t.fqname() in ('spaces', 'eol', 'comment', 'comment.start',
|
||||
'comment.data', 'comment.null', 'comment.end')
|
||||
|
||||
class Javascript(mode.Fundamental):
|
||||
modename = 'Javascript'
|
||||
extensions = ['.js']
|
||||
grammar = JavascriptGrammar
|
||||
tabbercls = JavascriptTabber
|
||||
tabbercls = JavascriptTabber2
|
||||
opentokens = ('delimiter',)
|
||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||
closetokens = ('delimiter',)
|
||||
|
|
Loading…
Reference in New Issue