annotate runtime/ftplugin/fortran.vim @ 29547:e9f9c092ff10

Added tag v9.0.0114 for changeset 8a243ecfe2dde381f8010e1133a656d19d666738
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Jul 2022 18:00:04 +0200
parents f8e9d5023bf6
children cf2ae76cbbf7
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
3492
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
2 " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, 77, 66)
29066
f8e9d5023bf6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
3 " Version: (v53) 2021 April 06 (updated 2022 May 22)
5400
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
4 " 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: 5400
diff changeset
5 " Usage: For instructions, do :help fortran-plugin from Vim
2398
0c8219a26bc9 More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 819
diff changeset
6 " Credits:
22565
17c4178f26ea Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
7 " Version 0.1 was created in September 2000 by Ajit Thakkar.
17c4178f26ea Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
8 " Since then, useful suggestions and contributions have been made, in order, by:
17c4178f26ea Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
9 " Stefano Zacchiroli, Hendrik Merx, Ben Fritz, David Barnett, Eisuke Kawashima,
24387
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
10 " Doug Kearns, and Fritz Reese.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " Only do these settings when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2398
diff changeset
17 let s:cposet=&cpoptions
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2398
diff changeset
18 set cpoptions&vim
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2398
diff changeset
19
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " Don't do other file type settings for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " 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: 5400
diff changeset
24 " 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: 5400
diff changeset
25 " buffer-local value
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
26 " > global value
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
27 " > file extension as in Intel ifort, gcc (gfortran), NAG, Pathscale, and Cray compilers
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if !exists("b:fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if exists("fortran_free_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " User guarantees free source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 elseif exists("fortran_fixed_source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " User guarantees fixed source form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let b:fortran_fixed_source = 1
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 7384
diff changeset
35 elseif expand("%:e") =~? '^f\%(90\|95\|03\|08\)$'
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
36 " 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: 5400
diff changeset
37 let b:fortran_fixed_source = 0
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 7384
diff changeset
38 elseif expand("%:e") =~? '^\%(f\|f77\|for\)$'
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
39 " Fixed-form file extension defaults
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
40 let b:fortran_fixed_source = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 else
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
42 " 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: 5400
diff changeset
43 " Assume fixed source form unless signs of free source form
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
44 " are detected in the first five columns of the first s:lmax lines.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " Detection becomes more accurate and time-consuming if more lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " 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: 5400
diff changeset
47 " the very top of each file and you have a fast computer.
2398
0c8219a26bc9 More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 819
diff changeset
48 let s:lmax = 500
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 if ( s:lmax > line("$") )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let s:lmax = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let b:fortran_fixed_source = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let s:ln=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 while s:ln <= s:lmax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let s:test = strpart(getline(s:ln),0,5)
2398
0c8219a26bc9 More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 819
diff changeset
56 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
57 let b:fortran_fixed_source = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let s:ln = s:ln + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endwhile
2398
0c8219a26bc9 More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 819
diff changeset
62 unlet! s:lmax s:ln s:test
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
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 comments and textwidth according to source type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 if (b:fortran_fixed_source == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 setlocal comments=:!,:*,:C
24387
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
69 " Fixed format requires a textwidth of 72 for code,
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
70 " but some vendor extensions allow longer lines
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
71 if exists("fortran_extended_line_length")
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
72 setlocal tw=132
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
73 elseif exists("fortran_cardimage_line_length")
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
74 setlocal tw=80
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
75 else
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
76 setlocal tw=72
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " If you need to add "&" on continued lines so that the code is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " compatible with both free and fixed format, then you should do so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 " in column 73 and uncomment the next line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 " setlocal tw=73
24387
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22565
diff changeset
81 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 setlocal comments=:!
5400
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
84 " Free format allows a textwidth of 132
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
85 setlocal tw=132
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 " Set commentstring for foldmethod=marker
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 setlocal cms=!%s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " 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
92 if !exists("fortran_have_tabs")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 setlocal expandtab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
5400
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
96 " Set 'formatoptions' to break text lines
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
97 setlocal fo+=t
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
99 setlocal include=^\\c#\\=\\s*include\\s\\+
3492
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
100 setlocal suffixesadd+=.f08,.f03,.f95,.f90,.for,.f,.F,.f77,.ftn,.fpp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " Define patterns for the matchit plugin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 if !exists("b:match_words")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 let s:notend = '\%(\<end\s\+\)\@<!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let s:notselect = '\%(\<select\s\+\)\@<!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 let s:notelse = '\%(\<end\s\+\|\<else\s\+\)\@<!'
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
107 let s:notprocedure = '\%(\s\+procedure\>\)\@!'
29066
f8e9d5023bf6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
108 let s:nothash = '\%(^\s*#\s*\)\@<!'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 let b:match_ignorecase = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 let b:match_words =
3492
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
111 \ '(:),' .
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 \ '\<select\s*case\>:' . s:notselect. '\<case\>:\<end\s*select\>,' .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 \ s:notelse . '\<if\s*(.\+)\s*then\>:' .
29066
f8e9d5023bf6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
114 \ s:nothash . '\<else\s*\%(if\s*(.\+)\s*then\)\=\>:' . s:nothash . '\<end\s*if\>,'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 \ s:notend . '\<do\>:\<end\s*do\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 \ s:notelse . '\<where\>:\<elsewhere\>:\<end\s*where\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 \ s:notend . '\<type\s*[^(]:\<end\s*type\>,'.
3492
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
119 \ s:notend . '\<forall\>:\<end\s*forall\>,'.
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
120 \ s:notend . '\<associate\>:\<end\s*associate\>,'.
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
121 \ s:notend . '\<enum\>:\<end\s*enum\>,'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 \ s:notend . '\<interface\>:\<end\s*interface\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 \ s:notend . '\<subroutine\>:\<end\s*subroutine\>,'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 \ s:notend . '\<function\>:\<end\s*function\>,'.
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 7
diff changeset
125 \ s:notend . '\<module\>' . s:notprocedure . ':\<end\s*module\>,'.
29066
f8e9d5023bf6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
126 \ s:notend . '\<program\>:\<end\s*program\>,'.
f8e9d5023bf6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
127 \ '\%(^\s*\)\@<=#\s*if\%(def\|ndef\)\=\>:\%(^\s*\)\@<=#\s*\%(elif\|else\)\>:\%(^\s*\)\@<=#\s*endif\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 " File filters for :browse e
22565
17c4178f26ea Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
131 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
3492
3482d151136b Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
132 let b:browsefilter = "Fortran Files (*.f;*.for;*.f77;*.f90;*.f95;*.f03;*.f08;*.fpp;*.ftn)\t*.f;*.for;*.f77;*.f90;*.f95;*.f03;*.f08;*.fpp;*.ftn\n" .
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 \ "All Files (*.*)\t*.*\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
5400
173c9c860e42 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 3492
diff changeset
136 let b:undo_ftplugin = "setl fo< com< tw< cms< et< inc< sua<"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 \ . "| unlet! b:match_ignorecase b:match_words b:browsefilter"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 let &cpoptions=s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 unlet s:cposet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 " vim:sw=2