Skip to content

Commit

Permalink
Register CursorMoved event only when required (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny authored Feb 8, 2020
1 parent 701c734 commit 2526438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 11 additions & 3 deletions autoload/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ function! s:register_events() abort
if exists('##TextChangedP')
autocmd TextChangedP * call s:on_text_document_did_change()
endif
autocmd CursorMoved * call s:on_cursor_moved()
if g:lsp_diagnostics_echo_cursor || g:lsp_highlight_references_enabled
autocmd CursorMoved * call s:on_cursor_moved()
endif
autocmd BufWinEnter,BufWinLeave,InsertEnter * call lsp#ui#vim#references#clean_references()
autocmd CursorMoved * if g:lsp_highlight_references_enabled | call lsp#ui#vim#references#highlight(v:false) | endif
augroup END
call s:on_text_document_did_open()
endfunction
Expand Down Expand Up @@ -239,7 +240,14 @@ endfunction
function! s:on_cursor_moved() abort
let l:buf = bufnr('%')
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif
call lsp#ui#vim#diagnostics#echo#cursor_moved()

if g:lsp_diagnostics_echo_cursor
call lsp#ui#vim#diagnostics#echo#cursor_moved()
endif

if g:lsp_highlight_references_enabled
call lsp#ui#vim#references#highlight(v:false)
endif
endfunction

function! s:call_did_save(buf, server_name, result, cb) abort
Expand Down
4 changes: 0 additions & 4 deletions autoload/lsp/ui/vim/diagnostics/echo.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
function! lsp#ui#vim#diagnostics#echo#cursor_moved() abort
if !g:lsp_diagnostics_echo_cursor
return
endif

if mode() isnot# 'n'
" dont' show echo only in normal mode
return
Expand Down

0 comments on commit 2526438

Please sign in to comment.