Vim function hints for C
Asked Answered
S

2

11

I'm trying to achieve something simple, usually called "function hints". For example, scintilla-based editors have it:

enter image description here

You type a name, and just get the prototype. There are a few problems with that in vim:

  • You have to rebuild the ctags to keep it up to date
  • You can't type C-X C-O after the (, you'll just get "Pattern not found"
  • You can't type C-X C-O in normal mode, the cursor will just jump around
  • You get the annoying preview window at the top

I've tried a few plugins; most of them mess things up even more [^1].Can anyone recommend a simple way to get just that ? A simple rectangle containing the function prototype and nothing more.

[^1] It's really mind-numbing how idiotic some of these plugins are. One plugin (I won't mention it) actually contained in the .vim file a list of functions from libc.

Schematize answered 2/7, 2012 at 20:34 Comment(3)
One plugin (I won't mention it) actually contained in the .vim file a list of functions from libc. What's wrong with that? You'll have a database somewhere, right? Or is the problem that the DB isn't stored in a secret unreadable proprietary format?Mc
@Mc That plugin already uses ctags.Schematize
:-) ok. Then it's a bad idea.Mc
P
8

ctags for autocompletion is a mess. I suggest you try a compiler based plugin such as clang-complete or gcc-sense (haven't tried this one). Advantages are:

  • more accuracy as what they do is pretty much compiling
  • compile errors are marked on the fly over the source code

You have to rebuild the ctags to keep it up to date

you don't need to deal with ctags (they are still useful to jump around though)

You can't type C-X C-O after the (, you'll just get "Pattern not found"

what would you expect?

You can't type C-X C-O in normal mode, the cursor will just jump around

you can always remap that sequence if you think it's a frequent mistake (something like nnoremap <C-x><C-o> a<C-x><C-o>)

You get the annoying preview window at the top

You can disable this by removing preview fromcompleteopt option. see :help completeopt

I'm using the following setup:

here

and some vimrc settings:

set pumheight=10             " so the complete menu doesn't get too big
set completeopt=menu,longest " menu, menuone, longest and preview
let g:SuperTabDefaultCompletionType='context'
let g:clang_complete_auto=0  " I can start the autocompletion myself, thanks..
let g:clang_snippets=1       " use a snippet engine for placeholders
let g:clang_snippets_engine='ultisnips'
let g:clang_auto_select=2    " automatically select and insert the first match

Enjoy!

Picked answered 16/8, 2012 at 20:17 Comment(0)
A
0

Try to use eclim (plugin for integration with Eclipse).

This solution is overheaded a lot but it works in all cases.

Avril answered 10/8, 2012 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.