Skip to content

Commit b495ed4

Browse files
committed
Prevent unnecessary completions
Now it only updates the completions in a buffer if there's been a change in a Clojure file somewhere. I think that's a fairly safe assumption.
1 parent 78bbfde commit b495ed4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

autoload/conjure.vim

+9-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ function! conjure#omnicomplete(findstart, base)
6969
endfunction
7070

7171
function! conjure#update_completions()
72-
if conjure#upsert_job() == 0
73-
call rpcnotify(s:jobid, "update_completions")
72+
if s:jobid != 0
73+
if exists("b:conjure_last_completion_changedtick") == 0
74+
let b:conjure_last_completion_changedtick = -1
75+
endif
76+
77+
if b:conjure_last_completion_changedtick < g:conjure_changedtick
78+
call rpcnotify(s:jobid, "update_completions")
79+
let b:conjure_last_completion_changedtick = g:conjure_changedtick
80+
endif
7481
endif
7582
endfunction
7683

plugin/conjure.vim

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ endfunction
6868
let g:conjure_refresh_dirs = ["src"]
6969
let g:conjure_refresh_args = ""
7070
let g:conjure_logging = 0
71+
let g:conjure_changedtick = 0
7172

7273
augroup conjure_bindings
7374
autocmd!
@@ -92,4 +93,6 @@ augroup conjure_bindings
9293
9394
autocmd FileType clojure setlocal omnifunc=conjure#omnicomplete
9495
autocmd CursorHold * if &ft ==# 'clojure' | call conjure#update_completions()
96+
autocmd TextChanged * if &ft ==# 'clojure' | let g:conjure_changedtick += 1
97+
autocmd TextChangedI * if &ft ==# 'clojure' | let g:conjure_changedtick += 1
9598
augroup END

0 commit comments

Comments
 (0)