|
1 | 1 | " vim-clojure-highlight
|
2 | 2 |
|
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 |
5 | 9 | endfunction
|
6 | 10 |
|
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 |
12 | 18 | endfunction
|
13 | 19 |
|
14 | 20 | " Pass zero explicitly to prevent highlighting local vars
|
15 | 21 | function! vim_clojure_highlight#syntax_match_references(...)
|
16 |
| - if !s:session_exists() | return | endif |
| 22 | + if !s:session_exists() | return | endif |
17 | 23 |
|
18 |
| - try |
19 |
| - call s:require() |
| 24 | + try |
| 25 | + call s:require() |
20 | 26 |
|
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' : '' |
23 | 28 |
|
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 |
28 | 33 | endfunction
|
29 |
| - |
30 |
| -" vim:noet:sw=8:ts=8 |
|
0 commit comments