From afce081b90c1e2c50c3507758c7558a0dfa1f33e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:18:03 +0200 Subject: Adding upstream version 2:8.2.2434. Signed-off-by: Daniel Baumann --- runtime/ftplugin/erlang.vim | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 runtime/ftplugin/erlang.vim (limited to 'runtime/ftplugin/erlang.vim') diff --git a/runtime/ftplugin/erlang.vim b/runtime/ftplugin/erlang.vim new file mode 100644 index 0000000..c775247 --- /dev/null +++ b/runtime/ftplugin/erlang.vim @@ -0,0 +1,83 @@ +" Vim ftplugin file +" Language: Erlang (http://www.erlang.org) +" Maintainer: Csaba Hoch +" Author: Oscar Hellström +" Contributors: Ricardo Catalinas Jiménez +" Eduardo Lopez (http://github.com/tapichu) +" Arvid Bjurklint (http://github.com/slarwise) +" Last Update: 2021-Jan-08 +" License: Vim license +" URL: https://github.com/vim-erlang/vim-erlang-runtime + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let &l:keywordprg = get(g:, 'erlang_keywordprg', 'erl -man') + +if get(g:, 'erlang_folding', 0) + setlocal foldmethod=expr + setlocal foldexpr=GetErlangFold(v:lnum) + setlocal foldtext=ErlangFoldText() +endif + +setlocal comments=:%%%,:%%,:% +setlocal commentstring=%%s + +setlocal formatoptions+=ro + +setlocal suffixesadd=.erl,.hrl + +let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")' +let &l:define = '^\s*-\%(define\|record\|type\|opaque\)' + +let s:erlang_fun_begin = '^\a\w*(.*$' +let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$' + +if !exists('*GetErlangFold') + function GetErlangFold(lnum) + let lnum = a:lnum + let line = getline(lnum) + + if line =~ s:erlang_fun_end + return '<1' + endif + + if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 + return '1' + endif + + if line =~ s:erlang_fun_begin + return '>1' + endif + + return '=' + endfunction +endif + +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 keywordprg< foldmethod< foldexpr< foldtext<" + \ . " comments< commentstring< formatoptions< suffixesadd< include<" + \ . " define<" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2 et -- cgit v1.2.3