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
*.pyo
*~
chardet

View File

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

View File

@ -186,7 +186,7 @@ class GitBlame(VcBlame):
if not m:
raise VcException("couldn't parse %r" % line)
groups = m.groups()
fields = list(groups[:-1])
fields = [s.decode('UTF-8') for s in groups[:-1]]
del fields[1]
if fields[1] == 'Not Committed Yet':
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'^```'),
PatternRule('md.escaped', r'\$[^$]+\$'),
RegionRule('md.bold', r'\*\*', MarkdownGrammar, r'\*\*'),
RegionRule('md.tt', r'``', MarkdownGrammar, r'``'),
@ -73,9 +75,9 @@ MarkdownGrammar.rules = [
class MdWrapParagraph(WrapParagraph):
limit = 75
limit = 72
class MdInsertSpace(TextInsertSpace):
limit = 75
limit = 72
wrapper = MdWrapParagraph
# white is for delimiters, operators, numbers
@ -157,7 +159,7 @@ class Markdown(Fundamental):
}
actions = [MdInsertSpace, MdWrapParagraph]
config = {
'md.margin': 75,
'markdown.margin': 72,
}
_bindings = {
'md-insert-space': ('SPACE',),

View File

@ -24,6 +24,8 @@ RoyGrammar.rules = [
RegionRule('string', "'", StringGrammar1, "'"),
RegionRule('string', '"', StringGrammar2, '"'),
#RegionRule('struct', '{', StructDefGrammar, '}'),
PatternRule('roy.number', r'-?[1-9][0-9]*(?:\.[0-9]+)?(?:e-?[0-9]+)?'),
PatternMatchRule('', '(' + word + ')(:)',
@ -37,67 +39,22 @@ RoyGrammar.rules = [
'roy.member', 'spaces', 'delimiter'),
PatternRule('roy.type', typ),
#PatternMatchRule('', '(type)( +)(' + typ + ')',
# 'roy.keyword', 'spaces', 'roy.type'),
PatternMatchRule('', '(let)( +)(' + word + ')',
'roy.keyword', 'spaces', 'roy.variable'),
PatternRule('delimiter', r'(?:->|<-|:|=|,|\(|\)|{|}|\[|\]|\+|\|)'),
PatternRule('roy.keyword', '(?:do|let|type)(?!' + chr2 + ')'),
PatternRule('roy.keyword', '(?:do|else|if|let|type)(?!' + chr2 + ')'),
PatternRule('roy.bareword', word),
]
#class JavascriptTabber2(tab.StackTabber2):
# fixed_indent = True
# open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
# close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
# control_tokens = {'roy.keyword': {'if': 1, 'else': 1, 'while': 1,
# 'do': 1, 'for': 1}}
# 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'))
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)
# white is for delimiters, operators, numbers
default = ('default', 'default')
@ -148,8 +105,8 @@ class Roy(Fundamental):
'roy.type': hi_magenta,
'roy.keyword': hi_cyan,
}
#config = {'rhino.cmd': 'rhino'}
#actions = [RhinoStart, RhinoLoadFile]
config = {'roy.cmd': 'roy'}
actions = [RoyStart]
_bindings = {
'close-paren': (')',),
'close-brace': ('}',),

View File

@ -58,9 +58,9 @@ class RSTGrammar(Grammar):
]
class RstWrapParagraph(WrapParagraph):
limit = 75
limit = 72
class RstInsertSpace(TextInsertSpace):
limit = 75
limit = 72
wrapper = RstWrapParagraph
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.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', '0[0-7]+[Ll]?'),