annotate runtime/indent/fortran.vim @ 8825:318eaa6fa973 v7.4.1700

commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 3 14:02:02 2016 +0200 patch 7.4.1700 Problem: Equivalence classes are not properly tested. Solution: Add tests for multi-byte and latin1. Fix an error. (Owen Leibman)
author Christian Brabandt <cb@256bit.org>
date Sun, 03 Apr 2016 14:15:05 +0200
parents ca19726d5e83
children 03fa8a51e9dc
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
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
2 " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, and 77)
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
3 " Version: 0.44
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
4 " Last Change: 2016 Jan. 26
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
5 " Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www2.unb.ca/~ajit/>
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
6 " Usage: For instructions, do :help fortran-indent from Vim
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
7 " Credits:
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
8 " Useful suggestions were made by: Albert Oliver Serra and Takuya Fujiwara.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if exists("b:did_indent")
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 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
16 let s:cposet=&cpoptions
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
17 set cpoptions&vim
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
18
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal indentkeys+==~end,=~case,=~if,=~else,=~do,=~where,=~elsewhere,=~select
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
20 setlocal indentkeys+==~endif,=~enddo,=~endwhere,=~endselect,=~elseif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
21 setlocal indentkeys+==~type,=~interface,=~forall,=~associate,=~block,=~enum
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
22 setlocal indentkeys+==~endforall,=~endassociate,=~endblock,=~endenum
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
23 if exists("b:fortran_indent_more") || exists("g:fortran_indent_more")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
24 setlocal indentkeys+==~function,=~subroutine,=~module,=~contains,=~program
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
25 setlocal indentkeys+==~endfunction,=~endsubroutine,=~endmodule
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
26 setlocal indentkeys+==~endprogram
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
27 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Determine whether this is a fixed or free format source file
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
30 " if this hasn't been done yet using the priority:
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
31 " buffer-local value
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
32 " > global value
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
33 " > file extension as in Intel ifort, gcc (gfortran), NAG, Pathscale, and Cray compilers
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 if !exists("b:fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if exists("fortran_free_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " User guarantees free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 elseif exists("fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " User guarantees fixed source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let b:fortran_fixed_source = 1
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
41 elseif expand("%:e") ==? "f\<90\|95\|03\|08\>"
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
42 " Free-form file extension defaults as in Intel ifort, gcc(gfortran), NAG, Pathscale, and Cray compilers
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
43 let b:fortran_fixed_source = 0
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
44 elseif expand("%:e") ==? "f\|f77\|for"
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
45 " Fixed-form file extension defaults
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
46 let b:fortran_fixed_source = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 else
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
48 " Modern fortran still allows both fixed and free source form
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
49 " Assume fixed source form unless signs of free source form
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
50 " are detected in the first five columns of the first s:lmax lines.
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
51 " Detection becomes more accurate and time-consuming if more lines
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " are checked. Increase the limit below if you keep lots of comments at
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6530
diff changeset
53 " 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
54 let s:lmax = 500
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if ( s:lmax > line("$") )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 let s:lmax = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let s:ln=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 while s:ln <= s:lmax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 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
62 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
63 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let s:ln = s:ln + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " Define the appropriate indent function but only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 if (b:fortran_fixed_source == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 setlocal indentexpr=FortranGetFixedIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 if exists("*FortranGetFixedIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 setlocal indentexpr=FortranGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 if exists("*FortranGetFreeIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 function FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 let ind = indent(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 let prevline=getline(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 " Strip tail comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 let prevstat=substitute(prevline, '!.*$', '', '')
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
89 let prev2line=getline(a:lnum-1)
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
90 let prev2stat=substitute(prev2line, '!.*$', '', '')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 "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
93 if exists("b:fortran_do_enddo") || exists("g:fortran_do_enddo")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 if prevstat =~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*do\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
95 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*end\s*do\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
98 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
102 "Add a shiftwidth to statements following if, else, else if, case,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
103 "where, else where, forall, type, interface and associate statements
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
104 if prevstat =~? '^\s*\(case\|else\|else\s*if\|else\s*where\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
105 \ ||prevstat=~? '^\s*\(type\|interface\|associate\|enum\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
106 \ ||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
107 \ ||prevstat=~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
108 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 " Remove unwanted indent after logical and arithmetic ifs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 if prevstat =~? '\<if\>' && prevstat !~? '\<then\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
111 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 endif
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 819
diff changeset
113 " Remove unwanted indent after type( statements
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
114 if prevstat =~? '^\s*type\s*('
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
115 let ind = ind - shiftwidth()
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 819
diff changeset
116 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
119 "Indent program units unless instructed otherwise
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
120 if !exists("b:fortran_indent_less") && !exists("g:fortran_indent_less")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
121 let prefix='\(\(pure\|impure\|elemental\|recursive\)\s\+\)\{,2}'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
122 let type='\(\(integer\|real\|double\s\+precision\|complex\|logical'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
123 \.'\|character\|type\|class\)\s*\S*\s\+\)\='
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
124 if prevstat =~? '^\s*\(module\|contains\|program\)\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
125 \ ||prevstat =~? '^\s*'.prefix.'subroutine\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
126 \ ||prevstat =~? '^\s*'.prefix.type.'function\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
127 \ ||prevstat =~? '^\s*'.type.prefix.'function\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
128 let ind = ind + shiftwidth()
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
129 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
130 if getline(v:lnum) =~? '^\s*contains\>'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
131 \ ||getline(v:lnum)=~? '^\s*end\s*'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
132 \ .'\(function\|subroutine\|module\|program\)\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
133 let ind = ind - shiftwidth()
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
134 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
135 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
136
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
137 "Subtract a shiftwidth from else, else if, elsewhere, case, end if,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
138 " end where, end select, end forall, end interface, end associate,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
139 " end enum, and end type statements
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*'
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
141 \. '\(else\|else\s*if\|else\s*where\|case\|'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
142 \. 'end\s*\(if\|where\|select\|interface\|'
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
143 \. 'type\|forall\|associate\|enum\|block\)\)\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
144 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 " Fix indent for case statement immediately after select
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
146 if prevstat =~? '\<select\s\+\(case\|type\)\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
147 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
151 "First continuation line
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
152 if prevstat =~ '&\s*$' && prev2stat !~ '&\s*$'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
153 let ind = ind + shiftwidth()
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
154 endif
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
155 if prevstat =~ '&\s*$' && prevstat =~ '\<else\s*if\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
156 let ind = ind - shiftwidth()
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
157 endif
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
158 "Line after last continuation line
6530
435956324539 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
159 if prevstat !~ '&\s*$' && prev2stat =~ '&\s*$' && prevstat !~? '\<then\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
160 let ind = ind - shiftwidth()
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
161 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2377
diff changeset
162
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 function FortranGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 "Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 "Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let ind=FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 function FortranGetFixedIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 let currline=getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 "Don't indent comments, continuation lines and labelled lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 if strpart(currline,0,6) =~ '[^ \t]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 let ind = indent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 "Find the previous line which is not blank, not a comment,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 "not a continuation line, and does not have a label
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 let lnum = v:lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 while lnum > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 let prevline=getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 if (prevline =~ "^[C*!]") || (prevline =~ "^\s*$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 \ || (strpart(prevline,5,1) !~ "[ 0]")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 " Skip comments, blank lines and continuation lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 let test=strpart(prevline,0,5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 if test =~ "[0-9]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 " Skip lines with statement numbers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 "First line must begin at column 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 return 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 let ind=FortranGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 let &cpoptions=s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 unlet s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 " vim:sw=2 tw=130