Mercurial > vim
annotate runtime/ftplugin/fortran.vim @ 12750:0b6c09957b43 v8.0.1253
patch 8.0.1253: still too many old style tests
commit https://github.com/vim/vim/commit/430dc5d360166ca5bb6a73f2c87ae53e09282ecb
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 2 21:04:47 2017 +0100
patch 8.0.1253: still too many old style tests
Problem: Still too many old style tests.
Solution: Convert a few more tests to new style. (Yegappan Lakshmanan,
closes #2272)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 02 Nov 2017 21:15:05 +0100 |
parents | aea5ebf352c4 |
children | bd021eb62e73 |
rev | line source |
---|---|
7 | 1 " Vim settings file |
3492 | 2 " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, 77, 66) |
7384
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
3 " Version: 0.50 |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
4 " Last Change: 2015 Nov. 30 |
5400 | 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:
5400
diff
changeset
|
6 " Usage: For instructions, do :help fortran-plugin from Vim |
2398 | 7 " Credits: |
5400 | 8 " Useful suggestions were made by Stefano Zacchiroli, Hendrik Merx, Ben |
9 " Fritz, and David Barnett. | |
7 | 10 |
11 " Only do these settings when not done yet for this buffer | |
12 if exists("b:did_ftplugin") | |
13 finish | |
14 endif | |
15 | |
3237 | 16 let s:cposet=&cpoptions |
17 set cpoptions&vim | |
18 | |
7 | 19 " Don't do other file type settings for this buffer |
20 let b:did_ftplugin = 1 | |
21 | |
22 " 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
|
23 " 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
|
24 " buffer-local value |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
25 " > global value |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
26 " > file extension as in Intel ifort, gcc (gfortran), NAG, Pathscale, and Cray compilers |
7 | 27 if !exists("b:fortran_fixed_source") |
28 if exists("fortran_free_source") | |
29 " User guarantees free source form | |
30 let b:fortran_fixed_source = 0 | |
31 elseif exists("fortran_fixed_source") | |
32 " User guarantees fixed source form | |
33 let b:fortran_fixed_source = 1 | |
7384
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
34 elseif expand("%:e") ==? "f\<90\|95\|03\|08\>" |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
35 " 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
|
36 let b:fortran_fixed_source = 0 |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
37 elseif expand("%:e") ==? "f\|f77\|for" |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
38 " Fixed-form file extension defaults |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
39 let b:fortran_fixed_source = 1 |
7 | 40 else |
7384
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
5400
diff
changeset
|
41 " 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
|
42 " 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
|
43 " are detected in the first five columns of the first s:lmax lines. |
7 | 44 " Detection becomes more accurate and time-consuming if more lines |
45 " 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
|
46 " the very top of each file and you have a fast computer. |
2398 | 47 let s:lmax = 500 |
7 | 48 if ( s:lmax > line("$") ) |
49 let s:lmax = line("$") | |
50 endif | |
51 let b:fortran_fixed_source = 1 | |
52 let s:ln=1 | |
53 while s:ln <= s:lmax | |
54 let s:test = strpart(getline(s:ln),0,5) | |
2398 | 55 if s:test !~ '^[Cc*]' && s:test !~ '^ *[!#]' && s:test =~ '[^ 0-9\t]' && s:test !~ '^[ 0-9]*\t' |
7 | 56 let b:fortran_fixed_source = 0 |
57 break | |
58 endif | |
59 let s:ln = s:ln + 1 | |
60 endwhile | |
2398 | 61 unlet! s:lmax s:ln s:test |
7 | 62 endif |
63 endif | |
64 | |
65 " Set comments and textwidth according to source type | |
66 if (b:fortran_fixed_source == 1) | |
67 setlocal comments=:!,:*,:C | |
68 " Fixed format requires a textwidth of 72 for code | |
69 setlocal tw=72 | |
70 " If you need to add "&" on continued lines so that the code is | |
71 " compatible with both free and fixed format, then you should do so | |
72 " in column 73 and uncomment the next line | |
73 " setlocal tw=73 | |
74 else | |
75 setlocal comments=:! | |
5400 | 76 " Free format allows a textwidth of 132 |
77 setlocal tw=132 | |
7 | 78 endif |
79 | |
80 " Set commentstring for foldmethod=marker | |
81 setlocal cms=!%s | |
82 | |
83 " Tabs are not a good idea in Fortran so the default is to expand tabs | |
84 if !exists("fortran_have_tabs") | |
85 setlocal expandtab | |
86 endif | |
87 | |
5400 | 88 " Set 'formatoptions' to break text lines |
89 setlocal fo+=t | |
7 | 90 |
819 | 91 setlocal include=^\\c#\\=\\s*include\\s\\+ |
3492 | 92 setlocal suffixesadd+=.f08,.f03,.f95,.f90,.for,.f,.F,.f77,.ftn,.fpp |
7 | 93 |
94 " Define patterns for the matchit plugin | |
95 if !exists("b:match_words") | |
96 let s:notend = '\%(\<end\s\+\)\@<!' | |
97 let s:notselect = '\%(\<select\s\+\)\@<!' | |
98 let s:notelse = '\%(\<end\s\+\|\<else\s\+\)\@<!' | |
819 | 99 let s:notprocedure = '\%(\s\+procedure\>\)\@!' |
7 | 100 let b:match_ignorecase = 1 |
101 let b:match_words = | |
3492 | 102 \ '(:),' . |
7 | 103 \ '\<select\s*case\>:' . s:notselect. '\<case\>:\<end\s*select\>,' . |
104 \ s:notelse . '\<if\s*(.\+)\s*then\>:' . | |
105 \ '\<else\s*\%(if\s*(.\+)\s*then\)\=\>:\<end\s*if\>,'. | |
106 \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'. | |
107 \ s:notend . '\<do\>:\<end\s*do\>,'. | |
108 \ s:notelse . '\<where\>:\<elsewhere\>:\<end\s*where\>,'. | |
109 \ s:notend . '\<type\s*[^(]:\<end\s*type\>,'. | |
3492 | 110 \ s:notend . '\<forall\>:\<end\s*forall\>,'. |
111 \ s:notend . '\<associate\>:\<end\s*associate\>,'. | |
112 \ s:notend . '\<enum\>:\<end\s*enum\>,'. | |
7 | 113 \ s:notend . '\<interface\>:\<end\s*interface\>,'. |
114 \ s:notend . '\<subroutine\>:\<end\s*subroutine\>,'. | |
115 \ s:notend . '\<function\>:\<end\s*function\>,'. | |
819 | 116 \ s:notend . '\<module\>' . s:notprocedure . ':\<end\s*module\>,'. |
7 | 117 \ s:notend . '\<program\>:\<end\s*program\>' |
118 endif | |
119 | |
120 " File filters for :browse e | |
121 if has("gui_win32") && !exists("b:browsefilter") | |
3492 | 122 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 | 123 \ "All Files (*.*)\t*.*\n" |
124 endif | |
125 | |
5400 | 126 let b:undo_ftplugin = "setl fo< com< tw< cms< et< inc< sua<" |
7 | 127 \ . "| unlet! b:match_ignorecase b:match_words b:browsefilter" |
128 | |
129 let &cpoptions=s:cposet | |
130 unlet s:cposet | |
131 | |
132 " vim:sw=2 |