parsonsmatt / intero-neovim

A neovim plugin for Intero, forked from ghcmod-vim
218 stars 28 forks source link

Slow and blocking start due to the use of `systemlist()` #161

Open lucc opened 5 years ago

lucc commented 5 years ago

Sometimes when I start neovim on a haskell file (nvim Foo.hs) I have a blank neovim screen sitting there for a while only showing the message "Foo.hs" 221 lines, 8209 characters at the bottom. It can take several seconds until the file is displayed.

Looking at running processes I see stack path --config-location which is called by intero with systemlist(). Now as the :help indicates systemlist() is the old and blocking way to call external processes. And the new job*() api is already extensively used by this plugin. So I suggest to replace all remaining system*() calls with job*() calls to make intero-neovim fully async.

parsonsmatt commented 5 years ago

I'm in favor of this! Thanks for reporting the improvement :)

rdnetto commented 5 years ago

+1 for replacing all usages of systemlist().

That said, it might be worthwhile trying to understand why that command takes so long. (I was able to reproduce it taking several seconds by running it directly, but only the first time, which makes me suspect something is getting cached.)

lucc commented 5 years ago

I had a look at the code and it was not obvious/simple how to refactor it because the return value of the call is used later on. If the variable is set asynchronously it might be accessed before it was set.