FYI. ----- Forwarded message from Bram Moolenaar ----- Date: Sat, 10 Sep 2005 14:46:00 +0200 From: Bram Moolenaar To: vim-dev@ Subject: Occult completion I have made a start with "occult completion". It's a bit like intellisense completion, but that is a trademark. It's going to be a bit unpredictable and mysterious, thus "occult" seemed to be a good name. And I needed something starting with an O, so that CTRL-X CTRL-O can be used. It is currently only working for C. This requires a tags file, which is used to find the information about typedefs, structures, etc. The original ctags didn't include sufficient information, thus I made a patch for Exuberant ctags to add this. See the help text below for where to find it. Without this patch it will still work for some things, depending on how the struct/typedef/etc. was declared. In the latest snapshot the file that does the completion is: runtime/autoload/ccomplete.vim. If you see something that can be improved, let me know. You will obviously have remarks about what needs to be improved. I'm especially interested in suggestions with a hint about how it can be implemented. Or an example of how another program does this. Do keep in mind that I want this to work on all systems, thus using some .dll file (as the insenvim project is doing) is not an option. We will need a popup menu to show the alternatives. This needs to be implemented for various GUIs. And for the console! If you want to work on this for other languages that would be great. C++ and Java should work in a similar way, since Exuberant ctags supports them. By the way: I fixed a problem that could cause a crash when using a prompt in a :for loop. The list that was looped over could be cleaned up by the garbage collector (it kicks in when waiting for a character to be typed). This especially happened when an error message was given inside a for loop, Vim could crash after the hit-enter prompt. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Filetype-specific remarks for occult completion *compl-occult-filetypes* C *ft-c-occult* Completion requires a tags file. You should use Exuberant ctags, because it adds extra information that is needed for completion. You can find it here: http://ctags.sourceforge.net/ For version 5.5.4 you need to add a patch that adds the "typename:" field: ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch If you want to complete system functions you can do something like this. Use ctags to generate a tags file for all the system header files: > % ctags -R -f ~/.vim/systags /usr/include /usr/local/include In your vimrc file add this tags file to the 'tags' option: > set tags+=~/.vim/systags When using CTRL-X CTRL-O after a name without any "." or "->" it is completed from the tags file directly. This works for any identifier, also function names. If you want to complete a local variable name, which does not appear in the tags file, use CTRL-P instead. When using CTRL-X CTRL-O after something that has "." or "->" Vim will attempt to recognize the type of the variable and figure out what members it has. This means only members valid for the variable will be listed. Vim doesn't include a C compiler, only the most obviously formatted declarations are recognized. Preprocessor stuff may cause confusion. When the same structure name appears in multiple places all possible members are included. -- $ echo pizza > /dev/oven /// Bram Moolenaar -- Bram@ -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html /// ----- End forwarded message ----- -- Regards, Sir Raorn.