Mercurial > vim
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 |
rev | line source |
---|---|
3281 | 1 " Vim ftplugin file |
2 " Language: Erlang | |
3356 | 3 " Author: Oscar Hellström <oscar@oscarh.net> |
4 " Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com> | |
3281 | 5 " Eduardo Lopez (http://github.com/tapichu) |
6 " License: Vim license | |
3356 | 7 " Version: 2012/01/25 |
3281 | 8 |
9 if exists('b:did_ftplugin') | |
10 finish | |
11 else | |
12 let b:did_ftplugin = 1 | |
13 endif | |
14 | |
15 if exists('s:did_function_definitions') | |
16 call s:SetErlangOptions() | |
17 finish | |
18 else | |
19 let s:did_function_definitions = 1 | |
20 endif | |
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 | 25 if !exists('g:erlang_keywordprg') |
26 let g:erlang_keywordprg = 'erl -man' | |
27 endif | |
28 | |
29 if !exists('g:erlang_folding') | |
30 let g:erlang_folding = 0 | |
31 endif | |
32 | |
3356 | 33 let s:erlang_fun_begin = '^\a\w*(.*$' |
34 let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$' | |
35 | |
3281 | 36 function s:SetErlangOptions() |
37 if g:erlang_folding | |
38 setlocal foldmethod=expr | |
39 setlocal foldexpr=GetErlangFold(v:lnum) | |
40 setlocal foldtext=ErlangFoldText() | |
41 endif | |
42 | |
43 setlocal comments=:%%%,:%%,:% | |
44 setlocal commentstring=%%s | |
45 | |
46 setlocal formatoptions+=ro | |
47 let &l:keywordprg = g:erlang_keywordprg | |
48 endfunction | |
49 | |
3356 | 50 function GetErlangFold(lnum) |
51 let lnum = a:lnum | |
52 let line = getline(lnum) | |
3281 | 53 |
3356 | 54 if line =~ s:erlang_fun_end |
55 return '<1' | |
56 endif | |
3281 | 57 |
3356 | 58 if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 |
59 return '1' | |
60 endif | |
3281 | 61 |
3356 | 62 if line =~ s:erlang_fun_begin |
63 return '>1' | |
64 endif | |
3281 | 65 |
3356 | 66 return '=' |
67 endfunction | |
3281 | 68 |
3356 | 69 function ErlangFoldText() |
70 let line = getline(v:foldstart) | |
71 let foldlen = v:foldend - v:foldstart + 1 | |
72 let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '') | |
73 if foldlen < 10 | |
74 let lines = ' ' . lines | |
75 endif | |
76 let retval = '+' . v:folddashes . lines | |
3281 | 77 |
3356 | 78 return retval |
79 endfunction | |
3281 | 80 |
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 |