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
- 0.13 Modeline support!
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:
ocaml_foldingturns on the folding;no_plugin_maporno_ocaml_mapsavoids the plugin to define key bindings.
For indentation, the value matters:
omlet_indentis the default indentationomlet_indent_structis the indentation of a value/type/method in its struct/classomlet_indent_letafter alet..in. Alet..inis not indented if it is after another one.omlet_indent_matchafter amatch..with.omlet_indent_functionafter afunction- If you need more, just ask...
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:
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:
For example:
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...
