views:

701

answers:

4

I don't know if this is possible at all, but still ... no harm in asking.

I'm using Vim to edit fortran files, old and new (.for and .f90). I'm trying to get completion, something alike Visual Studio's, so that when I have several subroutines defined in a file:

subroutine init ( ibc, nquad, ul, ur, xl, xr )
subroutine output ( f, ibc, indx, nsub, nu, ul, ur, xn )
subroutine phi ( il, x, phii, phiix, xleft, xrite )

and I call them somewhere:

call init(<cursor is here>

I get the list of arguments, so I don't have to remember them. If I understood right VS calls this "Intellisense".

Is something similar available in Vim (GVim72) and if it is, how to get it to work ? Any tips appreciated.


ldigas edit: I'd also be satisfied if I could just get the declaration line, as to say, when I type:

call init(<cursor is here>

and press completion key, Vim punches in the whole line, e.g.

call init( ibc, nquad, ul, ur, xl, xr )


ldigas edit2: 2 answers withdrawn so far ... interesting.


+2  A: 

The closest one should be vim intellisense. Unfortunately, it does not support Fortran yet...

Francis
Yes, I saw that while googling. Unfortunatelly, as you said, it doesn't help. I also found people mentioning some other (more vim like) alternatives here and there, but nothing related to fortran. Hoping someone else will know more ...
ldigas
+1  A: 

I think the closest you might be able to get is a vim feature that works similar to intellisense but let's you use the syntax highlighting file as the basis. Take a look at my .vimrc file here for an example. Basically it sets up auto complete for each of the listed types: if the filetype is supported by omnisense it uses it, otherwise it uses the syntax highlighting file.

syntax on
colorscheme elflord
set tabstop=4
set shiftwidth=4
set nu!
set et!
filetype on
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType sql set omnifunc=sqlcomplete#Complete
autocmd FileType c set omnifunc=ccomplete#Complete
if has("autocmd") && exists("+omnifunc")
    autocmd Filetype *
     \ if &omnifunc == "" |
     \  setlocal omnifunc=syntaxcomplete#Complete |
     \ endif
endif

Another possibility is to look on the vim.org website. For example, I found the following there ( even if it's not exactly what you're looking for it's just an example )

fortran_codecomplete.vim : Complete fortran constructs with

Hope this helps

Robert S. Barnes
Unfortunatelly, onmnifunc doesn't seem to work with fortran all that well. At least not in the way I need it.As for the second part, I know of Michael Goerz's plugin, but it is not what I'm needing. What he did is make a plugin, a kind of a snippets plugin. There are lots of those around, snipmate, xptemplate ... just to name a few. To put the long story short, no luck here. I still appreciate the effort though.
ldigas
+1  A: 

partial answer:

Okey, I got the first part:

Vim's whole line completion is called by

<Ctrl-X, Ctrl-L>

(if it is in a same file, which, btw, very often it isn't)

Unfortunatelly, if a subroutine declaration looks like

call assemble ( adiag, aleft, arite, f, h, indx, nl, node, nu, nquad, &
nsub, ul, ur, xn, xquad )

(where "&" is a continuation mark) that way won't work. Does anyone (come on you scripting vimmers) know of a way to avoid this behaviour ?

ldigas
+1  A: 

Quick & Dirty: Exuberant CTAGS

VIM understands tags very well. Unfortunately, this is not quite the slick behavior you seem to want: You'll wind up bouncing between windows, but I thought this was wonderful given that I had nothing else.

What may work is Photran, but I've never used it. However since it is open source and configurable you may find someone who has already gone down the road you're upon, e.g., there seems to be a VIM plugin. YMMV.

jaredor