fortran highlighting not working

25 views
Skip to first unread message

Srinath

unread,
Aug 26, 2008, 2:09:24 AM8/26/08
to vim_mac
With the most recent snapshot, the fortran highlighting for
fortran_free_form is not working.

Nico Weber

unread,
Aug 26, 2008, 8:24:18 AM8/26/08
to vim...@googlegroups.com
Hi Srinath,

On 26.08.2008, at 08:09, Srinath wrote:
>
> With the most recent snapshot, the fortran highlighting for
> fortran_free_form is not working.

does it work with the system stock `vim` in Terminal.app? If so,
please do `:e $VIMRUNTIME/syntax/fortran.vim`. What's the version of
that file (third line)? MacVim ships with version 0.88, which is the
official fortran syntax file -- also included with vim7.2 (7.0 even).

If highlighting for `fortran_free_form` stopped working, it's probably
because the fortran syntax file was changed.

Hm, after some googling I suspect that you're talking about
`fortran_free_source`. Could you elaborate on the problem?

Nico

Srinath

unread,
Aug 26, 2008, 10:21:52 AM8/26/08
to vim_mac
I got things to work by using the snap shot right before the last
stable release (7-2?). I will elaborate later today.

Srinath

unread,
Sep 2, 2008, 2:04:38 PM9/2/08
to vim_mac
Is it the case that the .gvimrc is sourced only once upon starting
MacVim? I now know what is my issue.
Normally in this modern age ;), one would have "let
fortran_free_source=1" in their .gvimrc file. If one was to get fancy
(hey...fortran is to a modern language ;)), then one would comment out
the quoted above and instead use:
"or comment-out the above and uncomment this:
let s:extfname = expand("%:e") " .f90 wil be free, .f fixed
if s:extfname ==? "f90"
let fortran_free_source=1
elseif s:extfname ==? "F90"
let fortran_free_source=1
else
unlet! fortran_free_source
endif

and free form would be selected because of file extension, and all
excluded would be considered fixed form. Now, if one starts with
"macvim <foo>.f90", then all further opened files will be opened with
"let fortran_free_source=1". But, if one starts "macvim <bar>.f" it
is properly highlighted as fixed form fortran, but if I open a new tab
for <foo>.f90, MacVim is still using "unlet fortran_free_source", and
thus is incorrectly highlighted.

So, how do get the .vimrc or .gvimrc source with every new tab? Also,
can I get an explanation for the different purposes for .vimrc
and .gvimrc?

Thanks so much for making MacVim what it is,
<>Srinath

Nico Weber

unread,
Sep 2, 2008, 3:40:59 PM9/2/08
to vim...@googlegroups.com
Hi Srinath,

On 02.09.2008, at 20:04, Srinath wrote:

> Is it the case that the .gvimrc is sourced only once upon starting
> MacVim?

Yes. That's normal vim behavior.

> So, how do get the .vimrc or .gvimrc source with every new tab?

You do not really want to do that :-) What you want is a file plugin.
`:h vimrc-filetype` gives an overview what this is, but a not very
good one. Here's what you want to do, in a nutshell:

1. Put `filetype plugin on` in your .vimrc

2. Add a file called `f90.vim` to the folder ~/.vim/ftplugin/. This
file will be execute every time you edit a .f90 file

3. Put `let fortran_free_source=1` in that file.

Now everything should work fine. If not, get back to us.

> Also, can I get an explanation for the different purposes for .vimrc
> and .gvimrc?

Sure. .vimrc is read ever time you start MacVim. .gvimrc is only read
when starting in gui mode (type `vim` in a terminal and hit enter to
see vim in non-gui mode).

>
HTH,
Nico

Srinath

unread,
Sep 3, 2008, 12:35:53 AM9/3/08
to vim_mac
I had to create ~/.vim/ftplugin directories. I added f90.vim
and also added a F90.vim with the solo line:

let fortran_free_source=1

This did not work. I must be missing some.
<>Srinath

Nico Weber

unread,
Sep 3, 2008, 5:05:55 AM9/3/08
to vim...@googlegroups.com
Hi,

On 03.09.2008, at 06:35, Srinath wrote:

> I had to create ~/.vim/ftplugin directories. I added f90.vim
> and also added a F90.vim with the solo line:
>
> let fortran_free_source=1
>
> This did not work. I must be missing some.

my fault, I'm just not familiar with that fortran stuff :-P So, remove
f90.vim and F90.vim and instead put a file called 'fortran.vim' into
~/.vim/ftplugin (the file needs to be called like the filetype it
should be loaded for -- the output of `:set filetype?` is hopefully
"fortran" on your system, too). In that file fortran.vim put

let s:extfname = expand("%:e")

if s:extfname ==? "f90"
let fortran_free_source=1

unlet! fortran_fixed_source
else
let fortran_fixed_source=1
unlet! fortran_free_source
endif

Note that this will work only if the "filetype plugin indent on" command
precedes the "syntax on" command in your .vimrc file.

(taken from `:h fortran`).

Does this help?

Nico

Reply all
Reply to author
Forward
0 new messages