annotate runtime/ftplugin/fortran.vim @ 819:23f82b5d2814 v7.0c10

updated for version 7.0c10
author vimboss
date Wed, 05 Apr 2006 20:41:53 +0000
parents 3fc0f57ecb91
children 0c8219a26bc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim settings file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Fortran90 (and Fortran95, Fortran77, F and elf90)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
3 " Version: 0.45
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
4 " Last Change: 2006 Apr. 03
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " URL: http://www.unb.ca/chem/ajit/ftplugin/fortran.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Usage: Do :help fortran-plugin from Vim
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
8 " Credits: Useful suggestions were made by Stefano Zacchiroli
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Only do these settings when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " Don't do other file type settings for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " Determine whether this is a fixed or free format source file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " if this hasn't been done yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if !exists("b:fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if exists("fortran_free_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " User guarantees free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 elseif exists("fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " User guarantees fixed source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " f90 and f95 allow both fixed and free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " assume fixed source form unless signs of free source form
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
30 " are detected in the first five columns of the first 250 lines
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " Detection becomes more accurate and time-consuming if more lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " are checked. Increase the limit below if you keep lots of comments at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " the very top of each file and you have a fast computer
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
34 let s:lmax = 250
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if ( s:lmax > line("$") )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let s:lmax = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let s:ln=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 while s:ln <= s:lmax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let s:test = strpart(getline(s:ln),0,5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 if s:test[0] !~ '[Cc*!#]' && s:test !~ '^ \+[!#]' && s:test =~ '[^ 0-9\t]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 let s:ln = s:ln + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " Set comments and textwidth according to source type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 if (b:fortran_fixed_source == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 setlocal comments=:!,:*,:C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " Fixed format requires a textwidth of 72 for code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 setlocal tw=72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " If you need to add "&" on continued lines so that the code is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " compatible with both free and fixed format, then you should do so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " in column 73 and uncomment the next line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " setlocal tw=73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 setlocal comments=:!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " Free format allows a textwidth of 132 for code but 80 is more usual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 setlocal tw=80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " Set commentstring for foldmethod=marker
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 setlocal cms=!%s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " Tabs are not a good idea in Fortran so the default is to expand tabs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if !exists("fortran_have_tabs")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 setlocal expandtab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " Set 'formatoptions' to break comment and text lines but allow long lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 setlocal fo+=tcql
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
77 setlocal include=^\\c#\\=\\s*include\\s\\+
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
78 setlocal suffixesadd+=.f95,.f90,.for,.f,.F,.f77,.ftn,.fpp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let s:cposet=&cpoptions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 set cpoptions-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " Define patterns for the matchit plugin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 if !exists("b:match_words")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 let s:notend = '\%(\<end\s\+\)\@<!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 let s:notselect = '\%(\<select\s\+\)\@<!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 let s:notelse = '\%(\<end\s\+\|\<else\s\+\)\@<!'
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
88 let s:notprocedure = '\%(\s\+procedure\>\)\@!'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 let b:match_ignorecase = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 let b:match_words =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 \ '\<select\s*case\>:' . s:notselect. '\<case\>:\<end\s*select\>,' .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 \ s:notelse . '\<if\s*(.\+)\s*then\>:' .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 \ '\<else\s*\%(if\s*(.\+)\s*then\)\=\>:\<end\s*if\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 \ s:notend . '\<do\>:\<end\s*do\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 \ s:notelse . '\<where\>:\<elsewhere\>:\<end\s*where\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 \ s:notend . '\<type\s*[^(]:\<end\s*type\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 \ s:notend . '\<interface\>:\<end\s*interface\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 \ s:notend . '\<subroutine\>:\<end\s*subroutine\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 \ s:notend . '\<function\>:\<end\s*function\>,'.
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
101 \ s:notend . '\<module\>' . s:notprocedure . ':\<end\s*module\>,'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 \ s:notend . '\<program\>:\<end\s*program\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 " File filters for :browse e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 if has("gui_win32") && !exists("b:browsefilter")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 let b:browsefilter = "Fortran Files (*.f;*.F;*.for;*.f77;*.f90;*.f95;*.fpp;*.ftn)\t*.f;*.F;*.for;*.f77;*.f90;*.f95;*.fpp;*.ftn\n" .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 \ "All Files (*.*)\t*.*\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 let b:undo_ftplugin = "setl fo< com< tw< cms< et< inc<"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 \ . "| unlet! b:match_ignorecase b:match_words b:browsefilter"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 let &cpoptions=s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 unlet s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 " vim:sw=2