Mercurial > vim
diff runtime/ftplugin/erlang.vim @ 23573:e2e2cc5d0856
Update runtime files.
Commit: https://github.com/vim/vim/commit/82be4849eed0b8fbee45bc8da99b685ec89af59a
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 11 19:40:15 2021 +0100
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 11 Jan 2021 19:45:05 +0100 |
parents | 5b7ea82bc18f |
children | f68f43043842 |
line wrap: on
line diff
--- a/runtime/ftplugin/erlang.vim +++ b/runtime/ftplugin/erlang.vim @@ -1,87 +1,83 @@ " Vim ftplugin file -" Language: Erlang +" Language: Erlang (http://www.erlang.org) +" Maintainer: Csaba Hoch <csaba.hoch@gmail.com> " 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) +" Last Update: 2021-Jan-08 " License: Vim license -" Version: 2012/01/25 +" URL: https://github.com/vim-erlang/vim-erlang-runtime if exists('b:did_ftplugin') - finish -else - let b:did_ftplugin = 1 + finish endif - -if exists('s:did_function_definitions') - call s:SetErlangOptions() - finish -else - let s:did_function_definitions = 1 -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' +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 -if !exists('g:erlang_folding') - let g:erlang_folding = 0 -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*\(%.*\)\?$' -function s:SetErlangOptions() - if g:erlang_folding - setlocal foldmethod=expr - setlocal foldexpr=GetErlangFold(v:lnum) - setlocal foldtext=ErlangFoldText() - endif - - setlocal comments=:%%%,:%%,:% - setlocal commentstring=%%s +if !exists('*GetErlangFold') + function GetErlangFold(lnum) + let lnum = a:lnum + let line = getline(lnum) - setlocal formatoptions+=ro - let &l:keywordprg = g:erlang_keywordprg -endfunction + if line =~ s:erlang_fun_end + return '<1' + endif -function GetErlangFold(lnum) - let lnum = a:lnum - let line = getline(lnum) + if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1 + return '1' + endif - if line =~ s:erlang_fun_end - return '<1' - endif + if line =~ s:erlang_fun_begin + 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 + return '=' + endfunction +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 !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 + return retval + endfunction +endif -call s:SetErlangOptions() - -let b:undo_ftplugin = "setlocal foldmethod< foldexpr< foldtext<" - \ . " comments< commentstring< formatoptions<" +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