-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctrl_e.vim
More file actions
31 lines (30 loc) · 949 Bytes
/
ctrl_e.vim
File metadata and controls
31 lines (30 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
fun s:unmatched(...) abort
let line = get(a:, 1, getline('.'))
let closers = {'[': ']', '{': '}', '(': ')', '"': '"'}
let lisps = ['clojure', 'racket', 'lisp', 'scheme', 'lfe', 'fennel']
if index(lisps, &ft) == -1
let closers["'"] = "'"
endif
let [context, in_quote] = [[], v:false]
for c in map(range(strlen(substitute(line, '[(\[{]\+\s*$', '', ''))), 'line[v:val]')
if in_quote
if context[0] == '\'
" Ignore escape character
call remove(context, 0)
elseif c == '\'
" Escape sequence
call insert(context, '\')
elseif c == context[0]
let [context, in_quote] = [context[1:], v:false]
endif
elseif has_key(closers, c)
" More nesting!
let in_quote = closers[c] == c
call insert(context, closers[c])
elseif c == get(context, 0, '')
call remove(context, 0)
endif
endfor
return get(context, 0, ";\<c-g>u")
endfun
inoremap <expr> <c-e> getcurpos()[2] == col('$') ? <sid>unmatched() : '<end>'