annotate runtime/ftplugin/erlang.vim @ 8487:ce789e3dc84d v7.4.1534

commit https://github.com/vim/vim/commit/846cdb227526272e2cd8ecba4f7168e2226cd633 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 11 18:52:22 2016 +0100 patch 7.4.1534 Problem: Compiler warning for shadowed variable. (Kazunobu Kuriyama) Solution: Rename it.
author Christian Brabandt <cb@256bit.org>
date Fri, 11 Mar 2016 19:00:06 +0100
parents 94601b379f38
children 5b7ea82bc18f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim ftplugin file
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Erlang
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
3 " Author: Oscar Hellström <oscar@oscarh.net>
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
4 " Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 " Eduardo Lopez (http://github.com/tapichu)
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 " License: Vim license
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
7 " Version: 2012/01/25
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 if exists('b:did_ftplugin')
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 finish
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 else
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 let b:did_ftplugin = 1
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 endif
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 if exists('s:did_function_definitions')
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 call s:SetErlangOptions()
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 finish
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 else
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 let s:did_function_definitions = 1
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 endif
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21
3410
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
22 let s:cpo_save = &cpo
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
23 set cpo&vim
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
24
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 if !exists('g:erlang_keywordprg')
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 let g:erlang_keywordprg = 'erl -man'
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 endif
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 if !exists('g:erlang_folding')
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 let g:erlang_folding = 0
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 endif
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
33 let s:erlang_fun_begin = '^\a\w*(.*$'
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
34 let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
35
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 function s:SetErlangOptions()
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 if g:erlang_folding
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 setlocal foldmethod=expr
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 setlocal foldexpr=GetErlangFold(v:lnum)
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40 setlocal foldtext=ErlangFoldText()
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 endif
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 setlocal comments=:%%%,:%%,:%
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 setlocal commentstring=%%s
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 setlocal formatoptions+=ro
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 let &l:keywordprg = g:erlang_keywordprg
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 endfunction
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
50 function GetErlangFold(lnum)
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
51 let lnum = a:lnum
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
52 let line = getline(lnum)
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
54 if line =~ s:erlang_fun_end
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
55 return '<1'
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
56 endif
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
58 if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
59 return '1'
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
60 endif
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
62 if line =~ s:erlang_fun_begin
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
63 return '>1'
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
64 endif
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
66 return '='
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
67 endfunction
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
69 function ErlangFoldText()
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
70 let line = getline(v:foldstart)
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
71 let foldlen = v:foldend - v:foldstart + 1
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
72 let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '')
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
73 if foldlen < 10
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
74 let lines = ' ' . lines
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
75 endif
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
76 let retval = '+' . v:folddashes . lines
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77
3356
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
78 return retval
b37888de599c Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
79 endfunction
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 call s:SetErlangOptions()
3410
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
82
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
83 let b:undo_ftplugin = "setlocal foldmethod< foldexpr< foldtext<"
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
84 \ . " comments< commentstring< formatoptions<"
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
85
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
86 let &cpo = s:cpo_save
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3356
diff changeset
87 unlet s:cpo_save