dart-lang/dart-vim-plugin

Vim very slow with .dart files

tjlaxs opened this issue · 15 comments

It seems like it is overwhelmed by something in this plugin. Is there any easy way to debug what causes it to get stuck for multiple seconds?

Do you have repro steps? Specifically, what is the set of steps you take that result in reproducible slowness?

Changing to the buffer with Dart file causes Vim to freeze for couple of seconds. And so does saving the Dart file. I wouldn't wonder if this had something to do with Syntastic or some other plugin. I will test if removing other plugins helps and report back.

I can't reproduce locally on vim 7.4.899. Tried three other machines with no slowdown seen either. Syntastic may well be the issue. IIRC it's backed by dartanalyzer and likely gets invoked on save. @polux has a set of patches to YouCompleteMe that runs against the analysis server instead and is much much faster. We're looking at getting those merged upstream.

Yeah, removing Syntastic makes this problem disappear.

Thanks for confirming. Closing the issue. It may be worth opening something against syntastic or dartanalyzer (performance). Once the YCM patches are landed, that's probably the way to go.

For someone may need this:
Add let g:loaded_syntastic_dart_dartanalyzer_checker = 0 in .vimrc to skip dartanalyzer in syntastic.

In there a way to address the performance issue other than disabling syntastic?

In there a way to address the performance issue other than disabling syntastic?

Not likely - this is most likely a deficiency in the approach syntastic is taking to use the dartanalyzer cli (which is known to be too slow for interactive use) over using the analysis server.

FWIW our recommended approach for in editor linting is to use a LSP plugin (like https://github.com/natebosch/vim-lsc) and either dart_language_server, or in upcoming versions of the SDK using the built in analysis server with --lsp. We're still working on the documentation for the latter.

That's the setup I'm currently using, but the feedback from dart_language_server is pretty non-obvious. Was hoping for a decent workaround. :/

but the feedback from dart_language_server is pretty non-obvious

How does it differ from syntastic? Which LSP client plugin are you using?

If you'd like to use syntastic specifically there isn't anything that can be done here to impact performance - you'd need to file an issue against their repo to ask them to change how they fetch errors.

I'm pretty new to vim, so please excuse my ignorance. I'm using https://github.com/natebosch/vim-lsc and https://github.com/natebosch/dart_language_server & am super appreciative of your contributions. I'm not married to using syntastic—do you recommend an alternative?

That's the setup I recommend and use - and I get diagnostics in a way that I'm happy with.

Since I've never used syntastic I don't know how it compares specifically. If you let me know how the current setup is "non-obvious" I might be able to improve it.

I think syntastic uses the sign gutter to put symbols on the left of the editor - is that the main thing you miss from syntastic that you don't get when you only use vim-lsc? Is there anything else?

With Syntastic...
Screen Shot 2019-03-13 at 3 59 13 PM

Without Syntastic... (No indication of error on line)
Screen Shot 2019-03-13 at 4 01 31 PM

Without Syntastic... (Minimal indication of error with cursor on line)
Screen Shot 2019-03-13 at 4 01 37 PM

I see 3 difference in the screenshots:

  1. The location list is open on the "with syntastic". vim-lsc already populates the location list so it should have the same behavior as what you're used to with syntastic, you need to ":lopen" to see it. Maybe syntastic is doing that for you?
  2. The highlighting for the error is different - underlined with syntastic and red with vim-lsc. You can configure either the Error highlight group, or the lscDiagnosticError (if you want to leave the default group alone) to change how it's highlighted. See :help highlight. It might take something like highlight lscDiagnosticError term=underline or maybe highlight lscDiagnosticError cterm=underline.
  3. syntastic is using the sign gutter (the red >> on the left). vim-lsc doesn't have support for this today but I filed natebosch/vim-lsc#165 to track as a feature request. I'm not sure how soon I'll be able to get to this. If its critical for you you might consider trying https://github.com/prabirshrestha/vim-lsp since they support signs AFAIK. I'm not sure whether they support the location list from the first point.

Thanks for the detailed response—super helpful. Didn't know this information was available in the location list. My errors are actually correctly highlighted & while it would be nice, I don't care too much about the gutter.

Seriously, thank you—hope this all helps someone else too!