Syntax hinting in Vim
Asked Answered
K

2

8

I've been using Vim for quite a while now, and while the code-completion (omni, dictionary, etc) works fine I've been missing one thing.

Syntax-hinting, so basically I'd like to know what arguments a function accepts, rather than look it up online I'd like to have it somewhere in Vim, preferably in a box above the current line or something.

Is there any way to achieve this, I mostly work with PHP, Python and C++ so I need it for those languages.

Edit: I do already have ctags installed, but from what I could tell it didn't provide syntax-hinting, tried it with PHP standard functions, dunno if I've overlooked something.

There's also the option of using snipMate and entering all standard library functions, but that's a lot of work, would've imagined that someone already did that (And yes there's something like ultiSnips that does but it's inferior to snipMate)

Keos answered 11/5, 2011 at 11:42 Comment(3)
You could have a look at ctags. I haven't explored it myself, but I keep meaning to. I know that it is supposed to allow completion of struct members, and suchlike. Not sure if it can do function arguments though.Homolographic
@Goulash Yeah I've already installed that, and while it does provide completion it doesn't seem to provide syntax hinting.Keos
I don't know for Python and C++ but in PHP, <C-x><C-o> brings both a contextual menu with possible completions and a little window with the "prototype" of the method, including arg names and types.Barbed
M
2

I think the plugin echofunc does that. When you are writing code, after you press ( the function prototype is displayed in the statusbar.

Check also the plugin srcexpl.vim which I think does something similar (I don't use it much though).

Monobasic answered 11/5, 2011 at 19:58 Comment(2)
Thanks for the tips, and it seems it does do what I want it to do, but there's 1 problem, which is ctags related, how do I get it to also show built-in/module functions from PHP/Python rather than just my own code?Keos
I don't know how exactly how to do that. I think you might want to ask a separate question for that.Monobasic
J
7

From the way it sounds I think you are looking for set completeopt+=preview. More information can be found at :help completeopt.

Jud answered 11/5, 2011 at 13:59 Comment(0)
M
2

I think the plugin echofunc does that. When you are writing code, after you press ( the function prototype is displayed in the statusbar.

Check also the plugin srcexpl.vim which I think does something similar (I don't use it much though).

Monobasic answered 11/5, 2011 at 19:58 Comment(2)
Thanks for the tips, and it seems it does do what I want it to do, but there's 1 problem, which is ctags related, how do I get it to also show built-in/module functions from PHP/Python rather than just my own code?Keos
I don't know how exactly how to do that. I think you might want to ask a separate question for that.Monobasic

© 2022 - 2024 — McMap. All rights reserved.