nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.26k stars 110 forks source link

Summary causes neovim to hang until it completes scanning #171

Closed cynicade closed 1 year ago

cynicade commented 1 year ago

Thanks for your work first of all, this is a fantastic plugin.

I have a question/feature request: is it possible to run the summary scan in the background/asynchronously? At work we have a monorepo with 6000+ test files πŸ˜… and when opening the summary for the first time it causes neovim to hang for upwards of 30-40 seconds until it finishes parsing all the files (at least that's what I assume is happening, I haven't really looked through the inner workings of neotest much). It doesn't hang the entire terminal, just neovim, so I figured it must just be blocking until it's done.

Setting concurrent to 1 for discovery doesn't help.

This could also be happening because I am using the neotest-vim-test adapter since there is no available adapter that supports mocha currently, haven't put any neotest "native" adapters through that torture yet.

Sorry if this has been asked/answered before, I couldn't find anything on this.

Nbd if there isn't something that can be done - everything still works great, this is just a minor annoyance.

Version info: Neovim: v0.8.1 release Neotest: commit https://github.com/nvim-neotest/neotest/commit/274d9f016c7a68991904972475a5f9d00e25fb84 Term: kitty 0.26.5 OS: macOS Ventura 13.0.1 on M1 Pro

rcarriga commented 1 year ago

Yeah this is due to using the vim-test adapter. It's not to do with the summary at all, that just kicks off the scanning. You'd have the same if you tried to run a test.

The issue is that because vim-test is implemented vimscript, all calls to it must be made synchronously and because it does a lot of regex parsing it is very heavy. I wouldn't recommend using it for such a large repo right now to be honest. There is new functionality to run code in a separate neovim process internally so that could be a potential solution to this but I'll have to investigate.

The best solution is to use a first class adapter. I'm not sure how different mocha would be from jest/vitest but that could be useful places to start for writing one yourself :smile: Getting a basic adapter started shouldn't be too difficult and it would perform far better

cynicade commented 1 year ago

Makes sense, I'll look into putting together an adapter for mocha then. Thanks! Feel free to close this πŸ™‚

rcarriga commented 1 year ago

The latest change to neotest-vim-test now uses a separate process to run vim-test functions so the editor should now not block when parsing. It won't speed it up at all and the recommended solution is still to use a better adapter but for those stuck with vim-test it should at least be a better experience :smile: