Index

Some Scala Stuff

I've created a vim syntax and indention file. This is my first time I came in contact with vim's inner workings and I did not even know that the editor has a complex macro language — it's quite amaising. I tried to match the standard highlighting behavior, assigning the "usual" highlight groups. For highlighting XML literals, you need to terminate multiline literals with a ";". Otherwise the highlighter does not find the end. The indenter does it the way I like. It automatically indent and dedent single line statement continuations. It even indents XML literals nicely.

Download the following files and put them into the specified directories:

Here is an example, generated by vim's html export feature.

/* NSC -- new scala compiler */
package scala.tools.nsc.ast.parser;

trait Parsers requires SyntaxAnalyzer {

  import global._;
  import posAssigner.atPos;

  class Parser(unit: CompilationUnit) {
    /** the markup parser */
    val xmlp = new MarkupParser(unit, in, Parser.this, true);

    object treeBuilder extends TreeBuilder {
      val global: Parsers.this.global.type = Parsers.this.global;
      def freshName(prefix: String): Name = unit.fresh.newName(prefix);
    }

    def syntaxError(pos: int, msg: String, skipIt: boolean): unit = {
      if (pos != in.errpos) {
        unit.error(pos, msg);
        in.errpos = pos;
      }
      if (skipIt) {
        in.skipping = true;
        skip();
        in.skipping = false;
      }
    }
  }
}