From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA15273; Thu, 23 Aug 2001 02:57:13 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA15206 for ; Thu, 23 Aug 2001 02:57:11 +0200 (MET DST) Received: from smtp.nwlink.com (smtp.nwlink.com [209.20.130.57]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f7N0vAf06067 for ; Thu, 23 Aug 2001 02:57:10 +0200 (MET DST) Received: from ip178.usw22.rb1.bel.nwlink.com (ip178.usw22.rb1.bel.nwlink.com [207.202.195.178]) by smtp.nwlink.com (8.9.3/8.9.1) with SMTP id RAA07919 for ; Wed, 22 Aug 2001 17:55:22 -0700 (PDT) Received: (qmail 15431 invoked by uid 500); 23 Aug 2001 00:56:58 -0000 Date: Wed, 22 Aug 2001 17:56:58 -0700 From: Michael Leary To: caml Subject: [Caml-list] Vim 6.0 OCaml indent file Message-ID: <20010822175658.C15239@jean.nwlink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This message sent separately to both of: Now that vim 6.0 is in beta, it seems like a good time for me to throw out what I've got so far (not much) for an ocaml ident file. It's been a while since I looked at this, and I don't rightly recall how spiffy it was when I left it. :-} I would most appreciate any comments, critcisms, pointers, patches, flames, and samples of money from around the world... I've tried to follow the official OCaml style guide, but I've also tried to choose consistency over fanciness -- mostly because its a lot easier to code, and I'm no genius in either indent files or OCaml. :) For reference, this is the notion of indenting that I've been working from. Indent file follows. (* either like the first one if not on one line, else like the second *) let ... in let ... in (* either like the first one if not on one line, else like the second *) try ... with try ... with ... (* either like the first one if not on one line, else like the second *) match ... with match ... with ... (* indent after a line ending with = *) = ... (* outdent when the line is just ;; *) ... ;; (* um... I forget... outdent a line ending in ;; seems off... *) ... ...;; (* indent after a line ending with 'then' *) (* outdent a line starting with 'else' *) then$ ... ^else (* indent after a line ending with 'begin' *) (* outdent a line starting with 'end' *) begin$ ... ^end " Vim indent file " Language: OCaml " Maintainer: Mike Leary " Last Change: 2001/06/28 " URL: http://www.nwlink.com/~leary/ocaml.vim " Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetOCamlIndent() setlocal nolisp setlocal nosmartindent setlocal indentkeys+==in,=with,=else,=end,=;;,=| setlocal textwidth=80 " Only define the function once. if exists("*GetOCamlIndent") finish endif function GetOCamlIndent() " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) " At the start of the file use zero indent. if lnum == 0 return 0 endif let ind = indent(lnum) " indent after a line starts with 'let' and doesn't end with 'in' if getline(lnum) =~ '^\s*\(\\)' && getline(lnum) !~ '\(\\)\s*$' let ind = ind + &sw endif " indent after a line starts with 'try' or 'match' and doesn't end with 'with' " and set the alignment for cases if getline(lnum) =~ '^\s*\(\\|\\)' && getline(lnum) !~ '\(\\)\s*$' let ind = ind + &sw let align = indent(v:lnum) endif " indent after a line ends with '=', 'then', 'begin', or '->' if getline(lnum) =~ '\(\\|\\|->\|=\)\s*$' let ind = ind + &sw endif " outdent immediately when a line starts with 'in', 'with', 'else', 'end', or ';;' if getline(v:lnum) =~ '^\s*\(\\|\\|\\|\\|;;\)' let ind = ind - &sw endif " outdent after a line ends with ';;', but had something before it if getline(lnum) =~ '\s*\S+\s*;;\s*$' let ind = ind - &sw endif " set indent to align when a line starts with '|' if getline(v:lnum) =~ '^\s*|' let ind = align endif return ind endfunction " vim:sw=2 -- Would you mind terribly much if I asked you to take your silly-assed problem down the hall? ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr