prabirshrestha / vim-lsp

async language server protocol plugin for vim and neovim
MIT License
3.1k stars 304 forks source link

vim-lsp makes UI slow when `folding` enabled #1506

Open jerinphilip opened 10 months ago

jerinphilip commented 10 months ago

Thanks for maintaining vim-lsp.

I'm ending up with a hung vim while working with large-files. In this case, it was clang/lib/Sema/SemaDecl.cpp.

I followed this stackoverflow profiling instructions to get the following information:

FUNCTIONS SORTED ON TOTAL TIME
count     total (s)      self (s)  function
  611  19.059380033   0.016334271  lsp#ui#vim#folding#foldexpr()
  609  18.972095684                <SNR>131_foldexpr()
   86   1.558753138   0.000159769  <SNR>127_next()
   65   1.037749521   0.000044500  <SNR>127_callback()
   21   0.521326467   0.000033880  lsp#utils#step#start()
   10   0.263457583   0.000229769  <SNR>98_createProd()
   10   0.260984649   0.000202970  <SNR>97_request_create()
   11   0.260954438   0.000305860  <SNR>97_ensure_flush()
   11   0.260345168   0.000273740  <SNR>97_ensure_start()
   11   0.259047981   0.000107589  <SNR>97_ensure_init()
   11   0.258392923   0.000165990  <SNR>97_ensure_conf()
   11   0.257676646   0.000196100  <SNR>97_ensure_open()
   11   0.256677479   0.016126057  <SNR>97_ensure_changed()
    2   0.237349699   0.000097549  lsp#ui#vim#folding#send_request()
    2   0.234569077   0.234523748  <SNR>131_set_textprops()
  159   0.157981743   0.001661786  <SNR>98_filterSourceCallback()
   43   0.154527913   0.000229310  <SNR>98_mapFSourceCallback()
   16   0.154335848   0.000237578  <SNR>98_debounceTimeTimerCallback()
   10   0.143830019   0.000050840  <SNR>98_filterConditionSource()
   10   0.143814668   0.000053680  <SNR>98_mapFSource()

FUNCTIONS SORTED ON SELF TIME
count     total (s)      self (s)  function
  609                18.972095684  <SNR>131_foldexpr()

I picked the following up from vim-lsp#folding. Commenting out gets vim editing interface usable once again:

" set foldmethod=expr
"   \ foldexpr=lsp#ui#vim#folding#foldexpr()
"   \ foldtext=lsp#ui#vim#folding#foldtext()

Not sure if a bug, please consider this a report with some reproducible information. Let me know if you need more information.