diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-12-29 19:44:40 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-12-29 19:44:40 +0100 |
commit | 95d82fdb668b746ac100a8b7d2aca38038150707 (patch) | |
tree | 19f2e80acbab5efe1d35630faafb5e24d7230fd8 /ftplugin/erlang.vim | |
parent | 73c518717741fb3ebb6822645d38f37ffae7c19b (diff) | |
download | vim-polyglot-95d82fdb668b746ac100a8b7d2aca38038150707.tar.gz vim-polyglot-95d82fdb668b746ac100a8b7d2aca38038150707.zip |
Update
Diffstat (limited to 'ftplugin/erlang.vim')
-rw-r--r-- | ftplugin/erlang.vim | 111 |
1 files changed, 50 insertions, 61 deletions
diff --git a/ftplugin/erlang.vim b/ftplugin/erlang.vim index 45eb68f6..b9720484 100644 --- a/ftplugin/erlang.vim +++ b/ftplugin/erlang.vim @@ -8,90 +8,79 @@ endif " Author: Oscar Hellström <oscar@oscarh.net> " Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com> " Eduardo Lopez (http://github.com/tapichu) +" Arvid Bjurklint (http://github.com/slarwise) " License: Vim license " Version: 2012/01/25 if exists('b:did_ftplugin') - finish -else - let b:did_ftplugin = 1 -endif - -if exists('s:did_function_definitions') - call s:SetErlangOptions() - finish -else - let s:did_function_definitions = 1 + finish endif +let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim -if !exists('g:erlang_keywordprg') - let g:erlang_keywordprg = 'erl -man' -endif +let &l:keywordprg = get(g:, 'erlang_keywordprg', 'erl -man') -if !exists('g:erlang_folding') - let g:erlang_folding = 0 +if get(g:, 'erlang_folding', 0) + setlocal foldmethod=expr + setlocal foldexpr=GetErlangFold(v:lnum) + setlocal foldtext=ErlangFoldText() endif -let s:erlang_fun_begin = '^\a\w*(.*$' -let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$' - -function s:SetErlangOptions() - if g:erlang_folding - setlocal foldmethod=expr - setlocal foldexpr=GetErlangFold(v:lnum) - setlocal foldtext=ErlangFoldText() - endif +setlocal comments=:%%%,:%%,:% +setlocal commentstring=%%s - setlocal comments=:%%%,:%%,:% - setlocal commentstring=%%s +setlocal formatoptions+=ro - setlocal formatoptions+=ro - let &l:keywordprg = g:erlang_keywordprg +setlocal suffixesadd=.erl,.hrl - setlocal suffixesadd=.erl,.hrl +let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")' +let &l:define = '^\s*-\%(define\|record\|type\|opaque\)' - let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")' - let &l:define = '^\s*-\%(define\|record\|type\|opaque\)' -endfunction - -function GetErlangFold(lnum) - let lnum = a:lnum - let line = getline(lnum) - - if line =~ s:erlang_fun_end - return '<1' - endif +let s:erlang_fun_begin = '^\a\w*(.*$' +let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$' - if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 - return '1' - endif +if !exists('*GetErlangFold') + function GetErlangFold(lnum) + let lnum = a:lnum + let line = getline(lnum) - if line =~ s:erlang_fun_begin - return '>1' - endif + if line =~ s:erlang_fun_end + return '<1' + endif - return '=' -endfunction + if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 + return '1' + endif -function ErlangFoldText() - let line = getline(v:foldstart) - let foldlen = v:foldend - v:foldstart + 1 - let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '') - if foldlen < 10 - let lines = ' ' . lines - endif - let retval = '+' . v:folddashes . lines + if line =~ s:erlang_fun_begin + return '>1' + endif - return retval -endfunction + return '=' + endfunction +endif -call s:SetErlangOptions() +if !exists('*ErlangFoldText') + function ErlangFoldText() + let line = getline(v:foldstart) + let foldlen = v:foldend - v:foldstart + 1 + let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '') + if foldlen < 10 + let lines = ' ' . lines + endif + let retval = '+' . v:folddashes . lines + + return retval + endfunction +endif -let b:undo_ftplugin = "setlocal foldmethod< foldexpr< foldtext<" - \ . " comments< commentstring< formatoptions< suffixesadd< include< define<" +let b:undo_ftplugin = "setlocal keywordprg< foldmethod< foldexpr< foldtext<" + \ . " comments< commentstring< formatoptions< suffixesadd< include<" + \ . " define<" let &cpo = s:cpo_save unlet s:cpo_save + +" vim: sw=2 et |