Mercurial > vim
annotate runtime/ftplugin/erlang.vim @ 26644:2fc1e528e0e1 v8.2.3851
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Commit: https://github.com/vim/vim/commit/265f811f5a2dac81d9698f5202a661a04ed095f1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 19 12:33:05 2021 +0000
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Problem: Vim9: overhead when comparing string, dict or function.
Solution: Call the intented compare function directly. Refactor to avoid
duplicated code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Dec 2021 13:45:03 +0100 |
parents | e2e2cc5d0856 |
children | f68f43043842 |
rev | line source |
---|---|
3281 | 1 " Vim ftplugin file |
23573 | 2 " Language: Erlang (http://www.erlang.org) |
3 " Maintainer: Csaba Hoch <csaba.hoch@gmail.com> | |
22723 | 4 " Author: Oscar Hellström <oscar@oscarh.net> |
5 " Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com> | |
3281 | 6 " Eduardo Lopez (http://github.com/tapichu) |
23573 | 7 " Arvid Bjurklint (http://github.com/slarwise) |
8 " Last Update: 2021-Jan-08 | |
3281 | 9 " License: Vim license |
23573 | 10 " URL: https://github.com/vim-erlang/vim-erlang-runtime |
3281 | 11 |
12 if exists('b:did_ftplugin') | |
23573 | 13 finish |
3281 | 14 endif |
23573 | 15 let b:did_ftplugin = 1 |
3281 | 16 |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
17 let s:cpo_save = &cpo |
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
18 set cpo&vim |
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
19 |
23573 | 20 let &l:keywordprg = get(g:, 'erlang_keywordprg', 'erl -man') |
21 | |
22 if get(g:, 'erlang_folding', 0) | |
23 setlocal foldmethod=expr | |
24 setlocal foldexpr=GetErlangFold(v:lnum) | |
25 setlocal foldtext=ErlangFoldText() | |
3281 | 26 endif |
27 | |
23573 | 28 setlocal comments=:%%%,:%%,:% |
29 setlocal commentstring=%%s | |
30 | |
31 setlocal formatoptions+=ro | |
32 | |
33 setlocal suffixesadd=.erl,.hrl | |
34 | |
35 let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")' | |
36 let &l:define = '^\s*-\%(define\|record\|type\|opaque\)' | |
3281 | 37 |
3356 | 38 let s:erlang_fun_begin = '^\a\w*(.*$' |
39 let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$' | |
40 | |
23573 | 41 if !exists('*GetErlangFold') |
42 function GetErlangFold(lnum) | |
43 let lnum = a:lnum | |
44 let line = getline(lnum) | |
3281 | 45 |
23573 | 46 if line =~ s:erlang_fun_end |
47 return '<1' | |
48 endif | |
3281 | 49 |
23573 | 50 if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 |
51 return '1' | |
52 endif | |
3281 | 53 |
23573 | 54 if line =~ s:erlang_fun_begin |
55 return '>1' | |
56 endif | |
3281 | 57 |
23573 | 58 return '=' |
59 endfunction | |
60 endif | |
3281 | 61 |
23573 | 62 if !exists('*ErlangFoldText') |
63 function ErlangFoldText() | |
64 let line = getline(v:foldstart) | |
65 let foldlen = v:foldend - v:foldstart + 1 | |
66 let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '') | |
67 if foldlen < 10 | |
68 let lines = ' ' . lines | |
69 endif | |
70 let retval = '+' . v:folddashes . lines | |
3281 | 71 |
23573 | 72 return retval |
73 endfunction | |
74 endif | |
3281 | 75 |
23573 | 76 let b:undo_ftplugin = "setlocal keywordprg< foldmethod< foldexpr< foldtext<" |
77 \ . " comments< commentstring< formatoptions< suffixesadd< include<" | |
78 \ . " define<" | |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
79 |
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
80 let &cpo = s:cpo_save |
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
3356
diff
changeset
|
81 unlet s:cpo_save |
23573 | 82 |
83 " vim: sw=2 et |