Skip to content

Commit 2526438

Browse files
authored
Register CursorMoved event only when required (#699)
1 parent 701c734 commit 2526438

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

autoload/lsp.vim

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ function! s:register_events() abort
189189
if exists('##TextChangedP')
190190
autocmd TextChangedP * call s:on_text_document_did_change()
191191
endif
192-
autocmd CursorMoved * call s:on_cursor_moved()
192+
if g:lsp_diagnostics_echo_cursor || g:lsp_highlight_references_enabled
193+
autocmd CursorMoved * call s:on_cursor_moved()
194+
endif
193195
autocmd BufWinEnter,BufWinLeave,InsertEnter * call lsp#ui#vim#references#clean_references()
194-
autocmd CursorMoved * if g:lsp_highlight_references_enabled | call lsp#ui#vim#references#highlight(v:false) | endif
195196
augroup END
196197
call s:on_text_document_did_open()
197198
endfunction
@@ -239,7 +240,14 @@ endfunction
239240
function! s:on_cursor_moved() abort
240241
let l:buf = bufnr('%')
241242
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif
242-
call lsp#ui#vim#diagnostics#echo#cursor_moved()
243+
244+
if g:lsp_diagnostics_echo_cursor
245+
call lsp#ui#vim#diagnostics#echo#cursor_moved()
246+
endif
247+
248+
if g:lsp_highlight_references_enabled
249+
call lsp#ui#vim#references#highlight(v:false)
250+
endif
243251
endfunction
244252

245253
function! s:call_did_save(buf, server_name, result, cb) abort

autoload/lsp/ui/vim/diagnostics/echo.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
function! lsp#ui#vim#diagnostics#echo#cursor_moved() abort
2-
if !g:lsp_diagnostics_echo_cursor
3-
return
4-
endif
5-
62
if mode() isnot# 'n'
73
" dont' show echo only in normal mode
84
return

0 commit comments

Comments
 (0)