-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathauto.vim
61 lines (50 loc) · 1.73 KB
/
auto.vim
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let s:save_cpo = &cpo
set cpo&vim
let g:iced#nrepl#auto#does_switch_session = get(g:, 'iced#nrepl#auto#does_switch_session', v:false)
let s:leaving = v:false
function! s:auto_switching_session() abort
if ! g:iced#nrepl#auto#does_switch_session | return | endif
if iced#nrepl#check_session_validity(v:false) | return | endif
let ext = expand('%:e')
if ext ==# 'cljs' && iced#nrepl#cljs_session() !=# ''
call iced#nrepl#change_current_session('cljs')
call iced#hook#run('session_switched', {'session': 'cljs'})
elseif ext ==# 'clj'
call iced#nrepl#change_current_session('clj')
call iced#hook#run('session_switched', {'session': 'clj'})
endif
endfunction
function! iced#nrepl#auto#winenter() abort
if !iced#nrepl#is_connected() | return | endif
call s:auto_switching_session()
" eval `in-ns` automatically
if ! iced#nrepl#check_session_validity(v:false) | return | endif
call iced#nrepl#ns#in()
endfunction
function! iced#nrepl#auto#bufread() abort
if !iced#nrepl#is_connected() | return | endif
call s:auto_switching_session()
if !iced#nrepl#check_session_validity(v:false) | return | endif
call iced#nrepl#ns#eval({_ -> ''})
call iced#format#set_indentexpr()
endfunction
function! iced#nrepl#auto#bufwrite_post() abort
let timer = {}
function! timer.callback(_) abort
if !s:leaving
call iced#lint#current_file()
endif
endfunction
call timer_start(500, timer.callback)
endfunction
function! iced#nrepl#auto#newfile() abort
if !iced#nrepl#is_connected() | return | endif
call iced#skeleton#new()
call iced#format#set_indentexpr()
endfunction
function! iced#nrepl#auto#leave() abort
let s:leaving = v:true
call iced#nrepl#disconnect()
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo