-
Notifications
You must be signed in to change notification settings - Fork 273
Description
Describe the bug
Running language client commands in buffers without language servers still tries to communicate the requests to the language client binary. This has two severe effects:
- The buffer filename is fetched (
LSP#filename). This takes a really long while for files on slow network mounts. - The full text of the buffer is sent using JSON. This takes a really long while for very large files (think strace logs).
I'm running into this because of LanguageClient#handleCursorMoved (set-up automatically and does LSP#filename) and because of my auto-hover on cursor moved setup. I can't even disable it for irrelevant buffers because there doesn't seem to be any way to check if the language client works for the current buffer (the autocommands are only fired on server start/stop so they aren't really useful here). Either way I think it should be done automatically.
Here's the profile for moving around a network file with stock min-vimrc:
FUNCTION LSP#filename()
Defined: ~/.config/nvim/plugged/LanguageClient-neovim/autoload/LSP.vim line 3
Called 198 times
Total time: 5.045398
Self time: 5.045398
count total (s) self (s)
" When executing autocommand, `%` might have already changed.
198 5.038637 let l:filename = expand('<afile>:p')
198 0.000953 if !l:filename
198 0.003873 let l:filename = expand('%:p')
198 0.000377 endif
198 0.000672 return l:filename
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
198 5.114235 0.024005 LanguageClient#handleCursorMoved()
198 5.045398 LSP#filename()
198 0.034872 0.020608 LanguageClient#Notify()
198 0.033183 <SNR>15_Highlight_Matching_Pair()
198 0.008365 LanguageClient#Write()
198 0.007587 0.004934 LSP#position()
198 0.005900 <SNR>31_SkipSendingMessage()
198 0.002373 LSP#viewport()
198 0.001383 LSP#line()
198 0.001270 LSP#character()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
198 5.045398 LSP#filename()
198 0.033183 <SNR>15_Highlight_Matching_Pair()
198 5.114235 0.024005 LanguageClient#handleCursorMoved()
198 0.034872 0.020608 LanguageClient#Notify()
198 0.008365 LanguageClient#Write()
198 0.005900 <SNR>31_SkipSendingMessage()
198 0.007587 0.004934 LSP#position()
198 0.002373 LSP#viewport()
198 0.001383 LSP#line()
198 0.001270 LSP#character()
Environment
- neovim/vim version (
nvim --versionorvim --version): 0.4.3 - This plugin version (
git rev-parse --short HEAD): 7c741d0 - This plugin's binary version (
bin/languageclient --version): 0.1.156 - Minimal vimrc content:
min-vimrc.vim and open a network file, or add the following and open a network or a very large file
function! DoNothingHandler(output)
endfunction
autocmd CursorMoved * call LanguageClient_textDocument_hover({'handle': v:true}, 'DoNothingHandler')To Reproduce
Steps to reproduce the behavior:
- Make a very large file, like strace some program to get a 9 MB text file.
nvim -u min-vimrc.vim that-file- Try to move the cursor around.
- It's really slow.
Current behavior
The vimscript part of the language client tries to do things on all buffers.
Expected behavior
It checks a buffer-local "is language server running here" variable and if that's false does nothing immediately.