lots of assorted mode updates

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2014-03-13 17:20:52 -04:00
parent 066d826fc9
commit 153b203510
8 changed files with 124 additions and 63 deletions

View File

@ -3,3 +3,4 @@ syntax: glob
*.pyc *.pyc
*.pyo *.pyo
*~ *~
chardet

View File

@ -177,7 +177,7 @@ class Application(object):
'haskell', 'erlang', 'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'haskell', 'erlang', 'iperl', 'iperlmini', 'ipython', 'ipythonmini',
'awk', 'shell', 'shellmini', 'fstab', 'yacc', 'pipe', 'mbox', 'awk', 'shell', 'shellmini', 'fstab', 'yacc', 'pipe', 'mbox',
'error', 'lua', 'lily', 'forth', 'ebnf', 'colortest', 'go', 'error', 'lua', 'lily', 'forth', 'ebnf', 'colortest', 'go',
'inform6', 'scala', 'markdown', 'roy', 'twine', 'inform6', 'scala', 'markdown', 'roy', 'twine', 'idris',
) )
for name in names: for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name)) exec("import mode.%s; mode.%s.install(self)" % (name, name))

View File

@ -186,7 +186,7 @@ class GitBlame(VcBlame):
if not m: if not m:
raise VcException("couldn't parse %r" % line) raise VcException("couldn't parse %r" % line)
groups = m.groups() groups = m.groups()
fields = list(groups[:-1]) fields = [s.decode('UTF-8') for s in groups[:-1]]
del fields[1] del fields[1]
if fields[1] == 'Not Committed Yet': if fields[1] == 'Not Committed Yet':
fields[1] = '' fields[1] = ''

100
mode/idris.py Normal file
View File

@ -0,0 +1,100 @@
import os.path
#from method.shell import Interact
from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
from tab import Tabber
class CommentGrammar(Grammar): pass
CommentGrammar.rules = [
RegionRule(r'comment', r'{-', CommentGrammar, r'-}'), #nested
PatternRule(r'data', r'(?:[^{-]|{(?!-)|-(?!}))+'),
]
class StringGrammar(Grammar):
rules = [
PatternRule(r'escaped', r'\\.'),
PatternRule(r'data', r'[^\\"]+'),
]
class IdrisGrammar(Grammar):
rules = [
PatternRule(r'comment', r'--.*$'),
RegionRule(r'comment', r'{-', CommentGrammar, r'-}'),
# %access and such
PatternMatchRule('x', r'(%[a-z]+)( +)([^ \t\n]+)', 'idris.keyword', 'spaces', 'idris.directive'),
# probably too simple
PatternRule(r'integer', r'-?[0-9]+'),
PatternRule(r'float', r'-?[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?|-?[0-9]+[eE][+-]?[0-9]+'),
PatternRule(r'char', r"'[^'\\]'"),
PatternRule(r'spaces', r'[ \t]+'),
PatternRule(r'eol', r'\n'),
PatternRule(r'delimiter', r'[\[\](){},;]'),
PatternRule(r'idris.xyz', r'(?:=>|->|<-|=|:)(?![-!#$%&\*\+./<=>\?@\\^|~:])'),
PatternMatchRule('x', r"(module)( +)([a-zA-Z0-9_']+)", "idris.keyword", "spaces", "idris.module"),
#PatternMatchRule('x', r"(record|data|codata|class)( +)([a-zA-Z0-9_']+)", "idris.keyword", "spaces", "idris.def"),
# maybe wrong?
PatternRule(r'idris.operator', r"[-!#$%&\*\+./<=>\?@\\^|~:]+"),
RegionRule(r'string', r'"', StringGrammar, r'"'),
PatternRule(r'idris.keyword', r"(?:with|where|using|try|trivial|total|then|term|syntax|solve|rewrite|refine|record|public|private|prefix|pattern|partial|parameters|of|namespace|mutual|module|let|intros|instance|infixr|infixl|infix|in|import|if|focus|exact|else|dsl|do|data|compute|codata|class|case|attack|abstract)(?![a-zA-Z0-9_'])"),
PatternRule(r'idris.name', r"['_]?[A-Z][a-zA-Z0-9_']+"),
PatternRule(r'idris.word', r"[a-zA-Z0-9_']+"),
]
class IdrisTabber(Tabber):
pass
c_default = ('default', 'default')
lo_magenta = ('magenta202', 'default')
hi_magenta = ('magenta505', 'default')
lo_red = ('red300', 'default')
hi_red = ('red511', 'default')
hi_orange = ('yellow531', 'default')
lo_orange = ('yellow520', 'default')
hi_yellow = ('yellow551', 'default')
lo_yellow = ('yellow330', 'default')
lo_green = ('green030', 'default')
hi_green = ('green050', 'default')
lo_cyan = ('cyan033', 'default')
hi_cyan = ('cyan155', 'default')
lo_blue = ('blue113', 'default')
hi_blue = ('blue225', 'default')
class Idris(Fundamental):
name = 'Idris'
extensions = ['.idr']
tabwidth = 2
commentc = '--'
grammar = IdrisGrammar
opentokens = ('delimiter',)
opentags = {'(': ')', '{': '}', '[': ']'}
closetokens = ('delimiter',)
closetags = {')': '(', '}': '{', ']': '['}
colors = {
'idris.keyword': hi_magenta,
'idris.module': hi_yellow,
'idris.name': hi_green,
'idris.xyz': hi_cyan,
'idris.directive': hi_orange,
}
_bindings = {
'close-paren': (')',),
'close-brace': ('}',),
'close-bracket': (']',),
}
#actions = [HugsStart, HugsLoadFile]
install = Idris.install

View File

@ -57,6 +57,8 @@ MarkdownGrammar.rules = [
RegionRule('md.code', r'^```.+$', LineGrammar, r'^```'), RegionRule('md.code', r'^```.+$', LineGrammar, r'^```'),
PatternRule('md.escaped', r'\$[^$]+\$'),
RegionRule('md.bold', r'\*\*', MarkdownGrammar, r'\*\*'), RegionRule('md.bold', r'\*\*', MarkdownGrammar, r'\*\*'),
RegionRule('md.tt', r'``', MarkdownGrammar, r'``'), RegionRule('md.tt', r'``', MarkdownGrammar, r'``'),
@ -73,9 +75,9 @@ MarkdownGrammar.rules = [
class MdWrapParagraph(WrapParagraph): class MdWrapParagraph(WrapParagraph):
limit = 75 limit = 72
class MdInsertSpace(TextInsertSpace): class MdInsertSpace(TextInsertSpace):
limit = 75 limit = 72
wrapper = MdWrapParagraph wrapper = MdWrapParagraph
# white is for delimiters, operators, numbers # white is for delimiters, operators, numbers
@ -157,7 +159,7 @@ class Markdown(Fundamental):
} }
actions = [MdInsertSpace, MdWrapParagraph] actions = [MdInsertSpace, MdWrapParagraph]
config = { config = {
'md.margin': 75, 'markdown.margin': 72,
} }
_bindings = { _bindings = {
'md-insert-space': ('SPACE',), 'md-insert-space': ('SPACE',),

View File

@ -24,6 +24,8 @@ RoyGrammar.rules = [
RegionRule('string', "'", StringGrammar1, "'"), RegionRule('string', "'", StringGrammar1, "'"),
RegionRule('string', '"', StringGrammar2, '"'), RegionRule('string', '"', StringGrammar2, '"'),
#RegionRule('struct', '{', StructDefGrammar, '}'),
PatternRule('roy.number', r'-?[1-9][0-9]*(?:\.[0-9]+)?(?:e-?[0-9]+)?'), PatternRule('roy.number', r'-?[1-9][0-9]*(?:\.[0-9]+)?(?:e-?[0-9]+)?'),
PatternMatchRule('', '(' + word + ')(:)', PatternMatchRule('', '(' + word + ')(:)',
@ -37,67 +39,22 @@ RoyGrammar.rules = [
'roy.member', 'spaces', 'delimiter'), 'roy.member', 'spaces', 'delimiter'),
PatternRule('roy.type', typ), PatternRule('roy.type', typ),
#PatternMatchRule('', '(type)( +)(' + typ + ')',
# 'roy.keyword', 'spaces', 'roy.type'),
PatternMatchRule('', '(let)( +)(' + word + ')', PatternMatchRule('', '(let)( +)(' + word + ')',
'roy.keyword', 'spaces', 'roy.variable'), 'roy.keyword', 'spaces', 'roy.variable'),
PatternRule('delimiter', r'(?:->|<-|:|=|,|\(|\)|{|}|\[|\]|\+|\|)'), PatternRule('delimiter', r'(?:->|<-|:|=|,|\(|\)|{|}|\[|\]|\+|\|)'),
PatternRule('roy.keyword', '(?:do|let|type)(?!' + chr2 + ')'), PatternRule('roy.keyword', '(?:do|else|if|let|type)(?!' + chr2 + ')'),
PatternRule('roy.bareword', word), PatternRule('roy.bareword', word),
] ]
#class JavascriptTabber2(tab.StackTabber2): class RoyStart(Interact):
# fixed_indent = True args = []
# open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} reuse = True
# close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} def _execute(self, w, **vargs):
# control_tokens = {'roy.keyword': {'if': 1, 'else': 1, 'while': 1, cmd = w.application.config.get('roy.cmd', './roy')
# 'do': 1, 'for': 1}} Interact._execute(self, w, bname='*Roy*', cmd=cmd)
# end_at_eof = False
# end_at_tokens = {'delimiter': {';': 1}}
# nocontinue_tokens = {'delimiter': {';': 1, ',': 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
# highlighter = self.mode.window.buffer.highlights[self.mode.name]
# if not highlighter.tokens[y]: return False
# t = highlighter.tokens[y][0]
# 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 RoyStart(Interact):
# args = []
# reuse = True
# def _execute(self, w, **vargs):
# cmd = w.application.config.get('roy.cmd', './roy')
# Interact._execute(self, w, bname='*Roy*', cmd=cmd)
#
#class RhinoLoadFile(RhinoStart):
# args = []
# reuse = True
# def _execute(self, w, **vargs):
# RhinoStart._execute(self, w, **vargs)
# b = w.application.get_buffer_by_name('*Rhino*')
# path = os.path.realpath(w.buffer.path)
# time.sleep(0.5)
# b.pipe_write('load("env.js");\n')
# time.sleep(0.5)
# b.pipe_write('load("%s");\n' % path)
#class JavascriptTagManager(TagManager):
# lang = 'Javascript'
# exts = set(('.js', '.json'))
# white is for delimiters, operators, numbers # white is for delimiters, operators, numbers
default = ('default', 'default') default = ('default', 'default')
@ -148,8 +105,8 @@ class Roy(Fundamental):
'roy.type': hi_magenta, 'roy.type': hi_magenta,
'roy.keyword': hi_cyan, 'roy.keyword': hi_cyan,
} }
#config = {'rhino.cmd': 'rhino'} config = {'roy.cmd': 'roy'}
#actions = [RhinoStart, RhinoLoadFile] actions = [RoyStart]
_bindings = { _bindings = {
'close-paren': (')',), 'close-paren': (')',),
'close-brace': ('}',), 'close-brace': ('}',),

View File

@ -58,9 +58,9 @@ class RSTGrammar(Grammar):
] ]
class RstWrapParagraph(WrapParagraph): class RstWrapParagraph(WrapParagraph):
limit = 75 limit = 72
class RstInsertSpace(TextInsertSpace): class RstInsertSpace(TextInsertSpace):
limit = 75 limit = 72
wrapper = RstWrapParagraph wrapper = RstWrapParagraph
class RstBuild(Method): class RstBuild(Method):

View File

@ -103,9 +103,10 @@ class ScalaGrammar(Grammar):
PatternRule('scala.reserved', '(?:yield|with|while|var|val|type|true|try|trait|throw|this|super|sealed|return|protected|private|package|override|object|null|new|match|macro|lazy|import|implicit|if|forSome|for|finally|final|false|extends|else|do|def|class|catch|case object|case class|case|abstract)(?!%s)' % chr2), PatternRule('scala.reserved', '(?:yield|with|while|var|val|type|true|try|trait|throw|this|super|sealed|return|protected|private|package|override|object|null|new|match|macro|lazy|import|implicit|if|forSome|for|finally|final|false|extends|else|do|def|class|catch|case object|case class|case|abstract)(?!%s)' % chr2),
PatternRule('scala.float', r'[0-9]+\.[0-9]*(?:[eE][0-9]+)?[FfDd]?'), # FIXME PatternRule('scala.float', r'-?[0-9]+\.[0-9]*(?:[eE][0-9]+)?[FfDd]?'), # FIXME
PatternRule('scala.float', r'-?(?:0|[1-9])[0-9]*[FfDd]'), # FIXME
PatternRule('scala.integer', '(?:0|[1-9])[0-9]*[Ll]?'), PatternRule('scala.integer', '-?(?:0|[1-9])[0-9]*[Ll]?'),
PatternRule('scala.integer', '0x[0-9A-Fa-f]+[Ll]?'), PatternRule('scala.integer', '0x[0-9A-Fa-f]+[Ll]?'),
PatternRule('scala.integer', '0[0-7]+[Ll]?'), PatternRule('scala.integer', '0[0-7]+[Ll]?'),