Skip to content

Commit 6ea8b85

Browse files
committed
Add support for matchit plugin
1 parent 8119998 commit 6ea8b85

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ftplugin/erlang.vim

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
" Contributors: Ricardo Catalinas Jiménez <[email protected]>
66
" Eduardo Lopez (http://github.com/tapichu)
77
" Arvid Bjurklint (http://github.com/slarwise)
8-
" Last Update: 2021-Nov-22
8+
" Paweł Zacharek (http://github.com/subc2)
9+
" Last Update: 2022-Sep-28
910
" License: Vim license
1011
" URL: https://github.com/vim-erlang/vim-erlang-runtime
1112

@@ -57,7 +58,7 @@ setlocal suffixesadd=.erl,.hrl
5758
let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")'
5859
let &l:define = '^\s*-\%(define\|record\|type\|opaque\)'
5960

60-
let s:erlang_fun_begin = '^\a\w*(.*$'
61+
let s:erlang_fun_begin = '^\l[A-Za-z0-9_@]*(.*$'
6162
let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
6263

6364
if !exists('*GetErlangFold')
@@ -99,6 +100,23 @@ let b:undo_ftplugin = "setlocal keywordprg< foldmethod< foldexpr< foldtext<"
99100
\ . " comments< commentstring< formatoptions< suffixesadd< include<"
100101
\ . " define<"
101102

103+
" The following lines enable the macros/matchit.vim plugin for
104+
" extended matching with the % key.
105+
if exists("loaded_matchit")
106+
let s:sw = &sw
107+
if exists('*shiftwidth')
108+
let s:sw = shiftwidth()
109+
endif
110+
111+
let b:match_words =
112+
\ '\<\%(begin\|case\|fun\|if\|maybe\|receive\|try\)\>' .
113+
\ ':\<\%(after\|catch\|else\|of\)\>' .
114+
\ ':\<end\>,' .
115+
\ '^\l[A-Za-z0-9_@]*' .
116+
\ ':^\%(\%(\t\| \{' . s:sw . '}\)\%([^\t\ %][^%]*\)\?\)\?;\s*\%(%.*\)\?$\|\.[\t\ %]\|\.$'
117+
let b:match_skip = 's:comment\|string\|erlangmodifier\|erlangquotedatom'
118+
endif
119+
102120
let &cpo = s:cpo_save
103121
unlet s:cpo_save
104122

0 commit comments

Comments
 (0)