Register CursorMoved event only when required (#699)

This commit is contained in:
itchyny
2020-02-08 22:17:57 +09:00
committed by GitHub
parent 701c734c91
commit 2526438c44
2 changed files with 11 additions and 7 deletions

View File

@@ -189,9 +189,10 @@ function! s:register_events() abort
if exists('##TextChangedP') if exists('##TextChangedP')
autocmd TextChangedP * call s:on_text_document_did_change() autocmd TextChangedP * call s:on_text_document_did_change()
endif 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 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 augroup END
call s:on_text_document_did_open() call s:on_text_document_did_open()
endfunction endfunction
@@ -239,7 +240,14 @@ endfunction
function! s:on_cursor_moved() abort function! s:on_cursor_moved() abort
let l:buf = bufnr('%') let l:buf = bufnr('%')
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif 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 endfunction
function! s:call_did_save(buf, server_name, result, cb) abort function! s:call_did_save(buf, server_name, result, cb) abort

View File

@@ -1,8 +1,4 @@
function! lsp#ui#vim#diagnostics#echo#cursor_moved() abort function! lsp#ui#vim#diagnostics#echo#cursor_moved() abort
if !g:lsp_diagnostics_echo_cursor
return
endif
if mode() isnot# 'n' if mode() isnot# 'n'
" dont' show echo only in normal mode " dont' show echo only in normal mode
return return