Skip to content

Commit bd93f48

Browse files
committed
Async highlight with acid
1 parent 9ac6cb8 commit bd93f48

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

autoload/vim_clojure_highlight.vim

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
" vim-clojure-highlight
22

3-
function! s:session_exists()
4-
return exists('g:fireplace_nrepl_sessions') && len(g:fireplace_nrepl_sessions)
3+
function! AsyncCljHighlightHandle(msg)
4+
let exists = a:msg[0]['value']
5+
if exists =~ 'nil'
6+
let buf = join(readfile(globpath(&runtimepath, 'autoload/vim_clojure_highlight.clj')), "\n")
7+
call AcidSendNrepl({'op': 'eval', 'code': "(do ". buf . ")"}, 'Ignore')
8+
endif
59
endfunction
610

7-
function! s:require()
8-
if fireplace#evalparse("(find-ns 'vim-clojure-highlight)") ==# ''
9-
let buf = join(readfile(globpath(&runtimepath, 'autoload/vim_clojure_highlight.clj')), "\n")
10-
call fireplace#session_eval('(do ' . buf . ')')
11-
endif
11+
function! AsyncCljHighlightRequire()
12+
call AcidSendNrepl({'op': 'eval', 'code': "(find-ns 'vim-clojure-highlight)"}, 'VimFn', 'AsyncCljHighlightHandle')
13+
endfunction
14+
15+
function! AsyncCljHighlightExec(msg)
16+
let highlight = a:msg[0]['value']
17+
exec highlight
1218
endfunction
1319

1420
" Pass zero explicitly to prevent highlighting local vars
1521
function! vim_clojure_highlight#syntax_match_references(...)
16-
if !s:session_exists() | return | endif
22+
if !s:session_exists() | return | endif
1723

18-
try
19-
call s:require()
24+
try
25+
call s:require()
2026

21-
let ns = "'" . fireplace#ns()
22-
let opts = (a:0 > 0 && !a:1) ? ' :local-vars false' : ''
27+
let opts = (a:0 > 0 && !a:1) ? ' :local-vars false' : ''
2328

24-
execute fireplace#evalparse("(vim-clojure-highlight/ns-syntax-command " . ns . opts . ")")
25-
let &syntax = &syntax
26-
catch /./
27-
endtry
29+
execute AcidSendNrepl({"op": "eval", "code": "(vim-clojure-highlight/ns-syntax-command " . ns . opts . ")"}, 'VimFn', 'AsyncCljHighlightExec')
30+
let &syntax = &syntax
31+
catch /./
32+
endtry
2833
endfunction
29-
30-
" vim:noet:sw=8:ts=8

0 commit comments

Comments
 (0)