From a08eadd0b85131c98691823b264b09404d727b68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Thu, 5 Feb 2015 16:20:17 -0500 Subject: [PATCH] misc: update README on info for the Nit omnifunc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- misc/README.md | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/misc/README.md b/misc/README.md index 3c8abfb..947112e 100644 --- a/misc/README.md +++ b/misc/README.md @@ -16,7 +16,7 @@ Then can add the brush to your html page: Vim is a powerful text editor and a favorite of the Nit team. The `misc/vim` directory provides Vim support for Nit source files. -### Install +## Install The simpler way to install nit for vim is with [pathogen][1]. @@ -31,7 +31,7 @@ Ensure that `~/.vimrc` contains [1]: https://github.com/tpope/vim-pathogen -### Features +## Features * Syntax highlighting * Automatic indentation @@ -40,9 +40,15 @@ Ensure that `~/.vimrc` contains [2]: https://github.com/scrooloose/syntastic -### Autocomplete +## Autocomplete -The Nit plugin offers better autocomplete by scanning all projects in the +The Nit plugin offers two kinds of autocompletion: complete and omnifunc. + +You can use both completion at the same time. They each have their own strengths and weaknesses. + +### Complete + +The Nit plugin can configure the `complete` option by scanning all projects in the current directory, and their dependencies. Add the following code to `~/.vimrc`, then use `ctrl-n` to open the @@ -62,3 +68,27 @@ Look at the functions defined in `misc/vim/plugin/nit.vim` for all possible usages. [3]: http://www.vim.org/scripts/script.php?script_id=1879 + +### Omnifunc + +The Nit plugin also defines an omnifunc which uses metadata files produced by nitpick which +is called by syntastic. +It is activated by default when editing a Nit source file, launch it using `ctrl-x ctrl-o`. +It will suggest entities names from the current context and display the corresponding documentation. +Once the correct completion has been selected, you can close the documentation preview window with `:pc`. + +The omnifunc applies a simple heuristic to recognize what kind of entities to display: +(This is a simplification some behaviors are missing.) + +* If the cursor follows `import`, it will list known modules. +* If it follows `new`, `super` or `class` it will list known classes. +* If it follows a `.`, it will list properties. +* If on an extern method declaration, it will list classes and properties. +* Otherwise, it will list keywords and properties. + +Make sure to save your Nit module if using syntastic or to manually call nitpick the generate +the metadata files before using the omnifunc. If there is no locally available metadata, it +will use general metadata in the plugin directory. + +The metadata files from nitpick are stored in `~/.vim/nit/`. This location can be customized with +the environment variable `NIT_VIM_DIR`. -- 1.7.9.5