From 2526438c448282e3c6986fbaba2ed034bbbd9ae5 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sat, 8 Feb 2020 22:17:57 +0900 Subject: [PATCH] Register CursorMoved event only when required (#699) --- autoload/lsp.vim | 14 +++++++++++--- autoload/lsp/ui/vim/diagnostics/echo.vim | 4 ---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/autoload/lsp.vim b/autoload/lsp.vim index ad0a062c..49600c67 100644 --- a/autoload/lsp.vim +++ b/autoload/lsp.vim @@ -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 @@ -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 diff --git a/autoload/lsp/ui/vim/diagnostics/echo.vim b/autoload/lsp/ui/vim/diagnostics/echo.vim index 923237fd..ab0c9f48 100644 --- a/autoload/lsp/ui/vim/diagnostics/echo.vim +++ b/autoload/lsp/ui/vim/diagnostics/echo.vim @@ -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