1 " This file is part of NIT ( http://www.nitlanguage.org ).
3 " Licensed under the Apache License, Version 2.0 (the "License");
4 " you may not use this file except in compliance with the License.
5 " You may obtain a copy of the License at
7 " http://www.apache.org/licenses/LICENSE-2.0
9 " Unless required by applicable law or agreed to in writing, software
10 " distributed under the License is distributed on an "AS IS" BASIS,
11 " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 " See the License for the specific language governing permissions and
13 " limitations under the License.
15 " Nit plugin for Vim, provides some advanced features
21 if exists("loaded_nit_plugin")
24 let loaded_nit_plugin = 1
26 " Scan all relevant Nit modules for the current directory to autocomplete
28 " The guard `g:nit_complete_done` ensures that its body is executed only
29 " once. The call to `nitls -M` analyzses the current directory. However,
30 " updating the module list can be forced using ForceNitComplete.
32 " To activate, add the following line to ~/.vimrc
34 " autocmd Filetype nit call NitComplete()
35 function NitComplete()
36 if !exists("g:nit_complete_done")
37 let g:nit_complete_done = 1
39 " Reset or backup the original complete
40 if !exists("g:nit_complete_backup")
41 let g:nit_complete_backup = &complete
43 silent let &complete = g:nit_complete_backup
47 " This gives us better results for Nit
49 set completeopt=longest,menuone
51 " Do not predict small 3 letters keywords (or their prefix), they slow down
52 " prediction and some also require double-enter on end of line.
53 let g:acp_behaviorKeywordIgnores = ['new', 'var', 'in', 'do', 'els', 'end', 'ret', 'for', 'fun']
55 " Use nitls to compute all interesting files from the current directory and the standard library
56 for file in split(system('nitls -M standard .', '\n'))
57 silent let &complete = &complete . ',s' . file
61 " Compatibility with AutoComplPop
62 let g:acp_completeOption = &complete
63 let g:acp_ignorecaseOption = &ignorecase
65 " Redraw in case the user pressed some keys while waiting
70 " Force updating the Nit modules used for autocomplete
72 " It is recommended to manually call this function as needed. It can be mapped
75 " map <F2> :call ForceNitComplete()
77 " For small projects (or fast computers) you might want to call it on each
79 function ForceNitComplete()
80 unlet! g:nit_complete_done