annotate runtime/indent/fortran.vim @ 4133:36fd800b8c6c v7.3.819

updated for version 7.3.819 Problem: Compiling without +eval and with Python isn't working. Solution: Add the eval feature when building with Python.
author Bram Moolenaar <bram@vim.org>
date Thu, 14 Feb 2013 22:11:39 +0100
parents 91e53bcb7946
children 435956324539
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 indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Fortran95 (and Fortran90, Fortran77, F and elf90)
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
3 " Version: 0.40
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
4 " Last Change: 2011 Dec. 28
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Usage: Do :help fortran-indent from Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
14 let s:cposet=&cpoptions
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
15 set cpoptions&vim
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
16
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal indentkeys+==~end,=~case,=~if,=~else,=~do,=~where,=~elsewhere,=~select
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
18 setlocal indentkeys+==~endif,=~enddo,=~endwhere,=~endselect,=~elseif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
19 setlocal indentkeys+==~type,=~interface,=~forall,=~associate,=~block,=~enum
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
20 setlocal indentkeys+==~endforall,=~endassociate,=~endblock,=~endenum
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
21 if exists("b:fortran_indent_more") || exists("g:fortran_indent_more")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
22 setlocal indentkeys+==~function,=~subroutine,=~module,=~contains,=~program
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
23 setlocal indentkeys+==~endfunction,=~endsubroutine,=~endmodule
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
24 setlocal indentkeys+==~endprogram
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
25 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " Determine whether this is a fixed or free format source file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " if this hasn't been done yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if !exists("b:fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 if exists("fortran_free_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " User guarantees free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 elseif exists("fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " User guarantees fixed source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " f90 and f95 allow both fixed and free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " assume fixed source form unless signs of free source form
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
39 " are detected in the first five columns of the first 250 lines
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 " Detection becomes more accurate and time-consuming if more lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 " are checked. Increase the limit below if you keep lots of comments at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " the very top of each file and you have a fast computer
2377
878562053ba3 Update Fortran indent and syntax file. (Ajit Thakkar)
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
43 let s:lmax = 500
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 if ( s:lmax > line("$") )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 let s:lmax = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let s:ln=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 while s:ln <= s:lmax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let s:test = strpart(getline(s:ln),0,5)
2377
878562053ba3 Update Fortran indent and syntax file. (Ajit Thakkar)
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
51 if s:test !~ '^[Cc*]' && s:test !~ '^ *[!#]' && s:test =~ '[^ 0-9\t]' && s:test !~ '^[ 0-9]*\t'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let s:ln = s:ln + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " Define the appropriate indent function but only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 if (b:fortran_fixed_source == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 setlocal indentexpr=FortranGetFixedIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 if exists("*FortranGetFixedIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 setlocal indentexpr=FortranGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if exists("*FortranGetFreeIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 endif
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 function FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 let ind = indent(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 let prevline=getline(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " Strip tail comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let prevstat=substitute(prevline, '!.*$', '', '')
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
78 let prev2line=getline(a:lnum-1)
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
79 let prev2stat=substitute(prev2line, '!.*$', '', '')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 "Indent do loops only if they are all guaranteed to be of do/end do type
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 840
diff changeset
82 if exists("b:fortran_do_enddo") || exists("g:fortran_do_enddo")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if prevstat =~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*do\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*end\s*do\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
91 "Add a shiftwidth to statements following if, else, else if, case,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
92 "where, else where, forall, type, interface and associate statements
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
93 if prevstat =~? '^\s*\(case\|else\|else\s*if\|else\s*where\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
94 \ ||prevstat=~? '^\s*\(type\|interface\|associate\|enum\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
95 \ ||prevstat=~?'^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*\(forall\|where\|block\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
96 \ ||prevstat=~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 " Remove unwanted indent after logical and arithmetic ifs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 if prevstat =~? '\<if\>' && prevstat !~? '\<then\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 819
diff changeset
102 " Remove unwanted indent after type( statements
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
103 if prevstat =~? '^\s*type\s*('
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 819
diff changeset
104 let ind = ind - &sw
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 819
diff changeset
105 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
108 "Indent program units unless instructed otherwise
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
109 if !exists("b:fortran_indent_less") && !exists("g:fortran_indent_less")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
110 let prefix='\(\(pure\|impure\|elemental\|recursive\)\s\+\)\{,2}'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
111 let type='\(\(integer\|real\|double\s\+precision\|complex\|logical'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
112 \.'\|character\|type\|class\)\s*\S*\s\+\)\='
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
113 if prevstat =~? '^\s*\(module\|contains\|program\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
114 \ ||prevstat =~? '^\s*'.prefix.'subroutine\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
115 \ ||prevstat =~? '^\s*'.prefix.type.'function\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
116 \ ||prevstat =~? '^\s*'.type.prefix.'function\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
117 let ind = ind + &sw
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
118 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
119 if getline(v:lnum) =~? '^\s*contains\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
120 \ ||getline(v:lnum)=~? '^\s*end\s*'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
121 \ .'\(function\|subroutine\|module\|program\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
122 let ind = ind - &sw
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
123 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
124 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
125
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
126 "Subtract a shiftwidth from else, else if, elsewhere, case, end if,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
127 " end where, end select, end forall, end interface, end associate,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
128 " end enum, and end type statements
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*'
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
130 \. '\(else\|else\s*if\|else\s*where\|case\|'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
131 \. 'end\s*\(if\|where\|select\|interface\|'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
132 \. 'type\|forall\|associate\|enum\)\)\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 " Fix indent for case statement immediately after select
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
135 if prevstat =~? '\<select\s\+\(case\|type\)\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
140 "First continuation line
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
141 if prevstat =~ '&\s*$' && prev2stat !~ '&\s*$'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
142 let ind = ind + &sw
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
143 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
144 "Line after last continuation line
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
145 if prevstat !~ '&\s*$' && prev2stat =~ '&\s*$'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
146 let ind = ind - &sw
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
147 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
148
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 function FortranGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 "Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 "Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 let ind=FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 function FortranGetFixedIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 let currline=getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 "Don't indent comments, continuation lines and labelled lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 if strpart(currline,0,6) =~ '[^ \t]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 let ind = indent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 "Find the previous line which is not blank, not a comment,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 "not a continuation line, and does not have a label
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let lnum = v:lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 while lnum > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 let prevline=getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 if (prevline =~ "^[C*!]") || (prevline =~ "^\s*$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 \ || (strpart(prevline,5,1) !~ "[ 0]")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 " Skip comments, blank lines and continuation lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 let test=strpart(prevline,0,5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 if test =~ "[0-9]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 " Skip lines with statement numbers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 "First line must begin at column 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 return 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 let ind=FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 let &cpoptions=s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 unlet s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 " vim:sw=2 tw=130