947112ee42ba6f0b3977b69ed02988825d8bea10
[nit.git] / misc / README.md
1 # gtksourceview (gedit and other GTK editors)
2 To install in your home, just link (or copy) the language definition file in ~/.local/share/gtksourceview-2.0/language-specs
3
4 # syntaxhighlighter
5
6 Nit brush for the Alex Gorbatchev's JS syntaxhighlighter.
7
8 To install the JS syntaxhighlighter, please refer to http://alexgorbatchev.com/SyntaxHighlighter/
9
10 Then can add the brush to your html page:
11
12         <script type="text/javascript" src="shBrushNit.js"></script>
13
14 # Vim
15
16 Vim is a powerful text editor and a favorite of the Nit team.
17 The `misc/vim` directory provides Vim support for Nit source files.
18
19 ## Install
20
21 The simpler way to install nit for vim is with [pathogen][1].
22
23     cd ~/.vim/bundle
24     ln -s /full/path/to/nit/misc/vim nit
25
26 Ensure that `~/.vimrc` contains
27
28     call pathogen#infect()
29     syntax on
30     filetype plugin indent on
31
32   [1]: https://github.com/tpope/vim-pathogen
33
34 ## Features
35
36  * Syntax highlighting
37  * Automatic indentation
38  * Syntax checker (require [Syntastic][2]).
39  * Autocomplete for whole projects using module importations
40
41   [2]: https://github.com/scrooloose/syntastic
42
43 ## Autocomplete
44
45 The Nit plugin offers two kinds of autocompletion: complete and omnifunc.
46
47 You can use both completion at the same time. They each have their own strengths and weaknesses.
48
49 ### Complete
50
51 The Nit plugin can configure the `complete` option by scanning all projects in the
52 current directory, and their dependencies.
53
54 Add the following code to `~/.vimrc`, then use `ctrl-n` to open the
55 autocomplete popup.
56
57 ~~~
58 " Compute Nit module dependencies for autocomplete on loading our first Nit module
59 autocmd Filetype nit call NitComplete()
60
61 " Map reloading Nit module dependencies to F2
62 map <F2> :call ForceNitComplete()<enter>
63 ~~~
64
65 The plugin is compatible with, and optimized for, [AutoComplPop][3].
66
67 Look at the functions defined in `misc/vim/plugin/nit.vim` for all possible
68 usages.
69
70   [3]: http://www.vim.org/scripts/script.php?script_id=1879
71
72 ### Omnifunc
73
74 The Nit plugin also defines an omnifunc which uses metadata files produced by nitpick which
75 is called by syntastic.
76 It is activated by default when editing a Nit source file, launch it using `ctrl-x ctrl-o`.
77 It will suggest entities names from the current context and display the corresponding documentation.
78 Once the correct completion has been selected, you can close the documentation preview window with `:pc`.
79
80 The omnifunc applies a simple heuristic to recognize what kind of entities to display:
81 (This is a simplification some behaviors are missing.)
82
83 * If the cursor follows `import`, it will list known modules.
84 * If it follows `new`, `super` or `class` it will list known classes.
85 * If it follows a `.`, it will list properties.
86 * If on an extern method declaration, it will list classes and properties.
87 * Otherwise, it will list keywords and properties.
88
89 Make sure to save your Nit module if using syntastic or to manually call nitpick the generate
90 the metadata files before using the omnifunc. If there is no locally available metadata, it
91 will use general metadata in the plugin directory.
92
93 The metadata files from nitpick are stored in `~/.vim/nit/`. This location can be customized with
94 the environment variable `NIT_VIM_DIR`.