OMLet

Distribué par vim.org, annoncé sur Freshmeat.

J'ai développé et je maintiens encore un mode d'indentation pour Caml sous Vim. OMLet indente à peu près comme le tuareg-mode d'emacs. Le résultat réjouit les adeptes de Vim frustrés et rend plus difficile le choix de l'éditeur pour les codeurs débutants. Voici un exemple bidon, et un autre plus réaliste.

OMLet est composé d'un fichier d'indentation, du fichier syntaxe officiel à peine modifié, des plugins officiels augmentés d'un folding pour replier les définitions toplevel et les modules/signatures/classes, ce qui est confortable sur les gros fichiers.

OMLet est déja dans la version unstable des ocaml-tools de Debian, et il est en passe d'être inclus dans les fichiers distribués par défaut avec VIm, en tant que mode OCaml par défaut.

Désolé, la suite n'est pas traduite en français...

Contents

News

Important

Please make sure that the following line is in your ~/.vimrc, otherwise indentation won't be loaded automatically: filetype plugin indent on

Customization

OMLet indentation can be customized by setting a few variables. This setting is usually done by adding a line like let variable = value in your .vimrc. For the general variables, only the existence of a binding is taken into account, not the value:

For indentation, the value matters:

I also recently added omlet_middle_comment, a boolean (0/1) for choosing whether or not you want * at every new line in your comments. Auto indentation still has problems with this, but reindenting works.

Here is a commented example:

(* Default setting, everything set to 2. Notations: * omlet_indent: _ * omlet_indent_let: . * omlet_indent_match: ~ * omlet_indent_function: - * omlet_indent_struct: , *) module Example = struct ,,let top = __let x = 1 in let y = 3 in ..baz foo __bar ; match x with ~~| Foo -> (function x --| Foo -> Bar --| Bar -> Foo) ~~| Bar -> (fun x -> x) end

Working with other people

If you work with somebody else using OMLet, it is a good idea to add an OCaml modeline to your files. Then, OMLet's customization will be the same for everybody. Also, it would be very nice if somebody write an OCaml modeline parser for Emacs/Tuareg. Here is the OCaml modeline syntax:

"(*:" "o"?"caml:" (param "=" value)* "*)"

For example:

(*:caml: let=0 match=0 *)

The available parameters are default, let, match, fun, struct, and you guess their meaning.

Omlet indents with spaces, so if you want a full compatibility with emacs's tuareg-mode, it is recommended to use space-only indentation with emacs: (setq-default indent-tabs-mode nil)

Misc tips

Key mappings are prefixed by <LocalLeader>, which defaults to '\'. If you find something like '.' or ',' more accessible, customize your .vimrc: let maplocalleader="."

If you've been using emacs for a while, you might be a tab addict. Adding the following line to your .vimrc will make tab run indentation when hit in insert mode (C-f is the default for that in VIm): autocmd FileType omlet set indentkeys+=,!^I

I also recommend using otags in order to have tags working on OCaml projects.

Why expand tabs ?

Soon...