annotate runtime/ftplugin/fortran.vim @ 7:3fc0f57ecb91 v7.0001

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