Mercurial > vim
annotate runtime/ftplugin/fortran.vim @ 24303:17b49af76766 v8.2.2692
patch 8.2.2692: Vim9: locked script variable can be changed
Commit: https://github.com/vim/vim/commit/f5906aa7807e9a14159cbc09a141138a2a068ab2
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 2 14:35:15 2021 +0200
patch 8.2.2692: Vim9: locked script variable can be changed
Problem: Vim9: locked script variable can be changed.
Solution: Check for locked value. (closes https://github.com/vim/vim/issues/8031)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 02 Apr 2021 14:45:06 +0200 |
parents | 17c4178f26ea |
children | 5c98ea5f5d6e |
rev | line source |
---|---|
7 | 1 " Vim settings file |
3492 | 2 " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, 77, 66) |
22565 | 3 " Version: (v52) 2020 October 07 |
5400 | 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 | 6 " Credits: |
22565 | 7 " Version 0.1 was created in September 2000 by Ajit Thakkar. |
8 " Since then, useful suggestions and contributions have been made, in order, by: | |
9 " Stefano Zacchiroli, Hendrik Merx, Ben Fritz, David Barnett, Eisuke Kawashima, | |
10 " and Doug Kearns. | |
7 | 11 |
12 " Only do these settings when not done yet for this buffer | |
13 if exists("b:did_ftplugin") | |
14 finish | |
15 endif | |
16 | |
3237 | 17 let s:cposet=&cpoptions |
18 set cpoptions&vim | |
19 | |
7 | 20 " Don't do other file type settings for this buffer |
21 let b:did_ftplugin = 1 | |
22 | |
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 | 28 if !exists("b:fortran_fixed_source") |
29 if exists("fortran_free_source") | |
30 " User guarantees free source form | |
31 let b:fortran_fixed_source = 0 | |
32 elseif exists("fortran_fixed_source") | |
33 " User guarantees fixed source form | |
34 let b:fortran_fixed_source = 1 | |
20115 | 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 | 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 | 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 | 45 " Detection becomes more accurate and time-consuming if more lines |
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 | 48 let s:lmax = 500 |
7 | 49 if ( s:lmax > line("$") ) |
50 let s:lmax = line("$") | |
51 endif | |
52 let b:fortran_fixed_source = 1 | |
53 let s:ln=1 | |
54 while s:ln <= s:lmax | |
55 let s:test = strpart(getline(s:ln),0,5) | |
2398 | 56 if s:test !~ '^[Cc*]' && s:test !~ '^ *[!#]' && s:test =~ '[^ 0-9\t]' && s:test !~ '^[ 0-9]*\t' |
7 | 57 let b:fortran_fixed_source = 0 |
58 break | |
59 endif | |
60 let s:ln = s:ln + 1 | |
61 endwhile | |
2398 | 62 unlet! s:lmax s:ln s:test |
7 | 63 endif |
64 endif | |
65 | |
66 " Set comments and textwidth according to source type | |
67 if (b:fortran_fixed_source == 1) | |
68 setlocal comments=:!,:*,:C | |
69 " Fixed format requires a textwidth of 72 for code | |
70 setlocal tw=72 | |
71 " If you need to add "&" on continued lines so that the code is | |
72 " compatible with both free and fixed format, then you should do so | |
73 " in column 73 and uncomment the next line | |
74 " setlocal tw=73 | |
75 else | |
76 setlocal comments=:! | |
5400 | 77 " Free format allows a textwidth of 132 |
78 setlocal tw=132 | |
7 | 79 endif |
80 | |
81 " Set commentstring for foldmethod=marker | |
82 setlocal cms=!%s | |
83 | |
84 " Tabs are not a good idea in Fortran so the default is to expand tabs | |
85 if !exists("fortran_have_tabs") | |
86 setlocal expandtab | |
87 endif | |
88 | |
5400 | 89 " Set 'formatoptions' to break text lines |
90 setlocal fo+=t | |
7 | 91 |
819 | 92 setlocal include=^\\c#\\=\\s*include\\s\\+ |
3492 | 93 setlocal suffixesadd+=.f08,.f03,.f95,.f90,.for,.f,.F,.f77,.ftn,.fpp |
7 | 94 |
95 " Define patterns for the matchit plugin | |
96 if !exists("b:match_words") | |
97 let s:notend = '\%(\<end\s\+\)\@<!' | |
98 let s:notselect = '\%(\<select\s\+\)\@<!' | |
99 let s:notelse = '\%(\<end\s\+\|\<else\s\+\)\@<!' | |
819 | 100 let s:notprocedure = '\%(\s\+procedure\>\)\@!' |
7 | 101 let b:match_ignorecase = 1 |
102 let b:match_words = | |
3492 | 103 \ '(:),' . |
7 | 104 \ '\<select\s*case\>:' . s:notselect. '\<case\>:\<end\s*select\>,' . |
105 \ s:notelse . '\<if\s*(.\+)\s*then\>:' . | |
106 \ '\<else\s*\%(if\s*(.\+)\s*then\)\=\>:\<end\s*if\>,'. | |
107 \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'. | |
108 \ s:notend . '\<do\>:\<end\s*do\>,'. | |
109 \ s:notelse . '\<where\>:\<elsewhere\>:\<end\s*where\>,'. | |
110 \ s:notend . '\<type\s*[^(]:\<end\s*type\>,'. | |
3492 | 111 \ s:notend . '\<forall\>:\<end\s*forall\>,'. |
112 \ s:notend . '\<associate\>:\<end\s*associate\>,'. | |
113 \ s:notend . '\<enum\>:\<end\s*enum\>,'. | |
7 | 114 \ s:notend . '\<interface\>:\<end\s*interface\>,'. |
115 \ s:notend . '\<subroutine\>:\<end\s*subroutine\>,'. | |
116 \ s:notend . '\<function\>:\<end\s*function\>,'. | |
819 | 117 \ s:notend . '\<module\>' . s:notprocedure . ':\<end\s*module\>,'. |
7 | 118 \ s:notend . '\<program\>:\<end\s*program\>' |
119 endif | |
120 | |
121 " File filters for :browse e | |
22565 | 122 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
3492 | 123 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 | 124 \ "All Files (*.*)\t*.*\n" |
125 endif | |
126 | |
5400 | 127 let b:undo_ftplugin = "setl fo< com< tw< cms< et< inc< sua<" |
7 | 128 \ . "| unlet! b:match_ignorecase b:match_words b:browsefilter" |
129 | |
130 let &cpoptions=s:cposet | |
131 unlet s:cposet | |
132 | |
133 " vim:sw=2 |