dag / vim-fish

Vim support for editing fish scripts
MIT License
431 stars 59 forks source link

Startup of vim-fish is insanely slow #34

Open avegancafe opened 8 years ago

avegancafe commented 8 years ago

I've been loving using fish, but I've found that the startup time of this plugin is super slow, upwards of 5 seconds sometimes. I've pasted below a bit of the output of my vim --startuptime vim.log test.fish command. Is there any way to improve the performance? I'm not sure if it's just me, but I'd definitely like to use this plugin without the startuptime lag

152.351  000.095  000.095: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/vimballPlugin.vim
152.531  000.138  000.138: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/zipPlugin.vim
152.600  002.106: loading plugins
152.606  000.006: inits 3
156.487  003.881: reading ShaDa
157.076  000.589: clearing screen
165.099  001.021  001.021: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/scripts.vim
2122.220  1956.397  1956.397: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
2122.991  000.027  000.027: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/indent/fish.vim
2123.407  000.110  000.110: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/syntax/fish.vim
2123.910  000.191  000.191: sourcing /Users/Kyle/.config/nvim/bundle/vim-airline/autoload/airline/extensions.vim
pierrebeaucamp commented 7 years ago

Any update on this? I had to uninstall vim-fish because of it

avegancafe commented 7 years ago

Ditto, still no updates from me. I just uninstalled it @pierrebeaucamp

ElijahLynn commented 7 years ago

Ubuntu 14.04, Fish 2.4.0, vim-fish 825853f (master) fast for me: The ftplugin/fish.vim lead is the longest of the loads but still 31ms.

048.776  001.217: loading plugins
048.917  000.141: loading packages
048.937  000.020: inits 3
049.570  000.633: reading viminfo
049.599  000.029: setting raw mode
049.608  000.009: start termcap
049.635  000.027: clearing screen
053.393  001.163  001.163: sourcing /usr/share/vim/vim74/scripts.vim
054.569  000.663  000.663: sourcing /home/elijah/.vim/bundle/vim-fish/syntax/fish.vim
086.425  031.327  031.327: sourcing /home/elijah/.vim/bundle/vim-fish/ftplugin/fish.vim
087.978  000.053  000.053: sourcing /home/elijah/.vim/bundle/vim-fish/indent/fish.vim
088.643  005.802: opening buffers
ElijahLynn commented 7 years ago

Can you checkout master from source and try? That way we can compare.

ElijahLynn commented 7 years ago

Also, @pierrebeaucamp are you also using Homebrew and Neovim? Is it easy for you try with normal Vim, not in home brew?

pierrebeaucamp commented 7 years ago

I'm using Neovim. I checked out master, but it still takes multiple seconds to load. Longest file to load is ftplugin/fish.vim as well, which takes nearly 2 seconds.

avegancafe commented 7 years ago

This seems to have fixed it for myself in both vim and neovim (sorry @pierrebeaucamp!), thanks for the update @ElijahLynn

ElijahLynn commented 7 years ago

@kyleholzinger So to confirm, you are using master, Homebrew and Neovim or Vim and the speed is normal now and it appears that using master resolved the issue?

avegancafe commented 7 years ago

@ElijahLynn Yes sir! I'm on master, installed both Vim and NeoVim with homebrew, and startup is all back to normal (at most 100ms or so).

gmile commented 7 years ago

I'm running into the slowness issue as well.

I use:

Both installed via homebrew.

I ran:

$ nvim --startuptime vim.log .config/fish/config.fish

Click "Details" below to see the log. Note the following line:

2901.355  2805.314  2805.314: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
$ cat vim.log times in msec clock self+sourced self: sourced script clock elapsed: other lines 000.010 000.010: --- NVIM STARTING --- 000.646 000.636: locale set 001.511 000.865: inits 1 001.529 000.018: window checked 002.118 000.589: parsing arguments 002.122 000.005: expanding arguments 002.181 000.059: inits 2 002.324 000.143: init highlight 003.039 000.317 000.317: sourcing /Users/gmile/.config/nvim/autoload/pathogen.vim 031.817 000.092 000.092: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/ftdetect/apiblueprint.vim 032.014 000.041 000.041: sourcing /Users/gmile/.config/nvim/bundle/rust.vim/ftdetect/rust.vim 032.268 000.151 000.151: sourcing /Users/gmile/.config/nvim/bundle/vim-elixir/ftdetect/elixir.vim 032.549 000.178 000.178: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftdetect/fish.vim 032.764 019.438 018.976: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/filetype.vim 032.970 000.047 000.047: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/ftplugin.vim 033.161 000.040 000.040: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/indent.vim 033.821 000.224 000.224: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim 033.957 000.522 000.298: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/synload.vim 033.996 000.735 000.213: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syntax.vim 034.676 000.181 000.181: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim 035.079 000.183 000.183: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim 041.581 007.486 007.122: sourcing /Users/gmile/.config/nvim/bundle/base16-vim/colors/base16-default-dark.vim 041.667 039.154 011.091: sourcing /Users/gmile/.config/nvim/init.vim 041.675 000.197: sourcing vimrc file(s) 041.976 000.085 000.085: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/plugin/apiary.vim 042.129 000.102 000.102: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/plugin/apiblueprint.vim 043.710 001.399 001.399: sourcing /Users/gmile/.config/nvim/bundle/bufexplorer/plugin/bufexplorer.vim 044.782 000.439 000.439: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim 045.039 001.153 000.714: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/plugin/ctrlp.vim 046.422 000.252 000.252: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/autoload/nerdtree.vim 048.782 000.942 000.942: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/path.vim 049.114 000.194 000.194: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/menu_controller.vim 049.369 000.128 000.128: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/menu_item.vim 049.667 000.174 000.174: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/key_map.vim 050.119 000.327 000.327: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/bookmark.vim 050.614 000.366 000.366: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim 051.352 000.609 000.609: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim 051.804 000.325 000.325: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/opener.vim 052.305 000.375 000.375: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/creator.vim 052.508 000.078 000.078: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/flag_set.vim 052.854 000.222 000.222: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/nerdtree.vim 053.487 000.509 000.509: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/ui.vim 053.649 000.039 000.039: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/event.vim 053.834 000.061 000.061: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/notifier.vim 054.655 000.683 000.683: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim 073.828 000.105 000.105: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim 074.550 000.647 000.647: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim 074.818 029.507 023.470: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/plugin/NERD_tree.vim 075.021 000.048 000.048: sourcing /Users/gmile/.config/nvim/bundle/rust.vim/plugin/rust.vim 079.319 004.125 004.125: sourcing /Users/gmile/.config/nvim/bundle/vim-fugitive/plugin/fugitive.vim 080.113 000.219 000.219: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/gzip.vim 080.175 000.013 000.013: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/health.vim 080.282 000.064 000.064: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/man.vim 080.914 000.587 000.587: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/matchit.vim 081.153 000.192 000.192: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/matchparen.vim 081.705 000.496 000.496: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/netrwPlugin.vim 081.850 000.080 000.080: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/rplugin.vim 081.922 000.016 000.016: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/rrhelper.vim 082.106 000.123 000.123: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/shada.vim 082.204 000.035 000.035: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/spellfile.vim 082.439 000.175 000.175: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tarPlugin.vim 082.610 000.112 000.112: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tohtml.vim 082.693 000.029 000.029: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tutor.vim 082.961 000.215 000.215: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/zipPlugin.vim 083.052 002.603: loading plugins 083.263 000.210: loading packages 083.273 000.010: inits 3 087.346 004.073: reading ShaDa 090.208 002.861: clearing screen 095.523 000.683 000.683: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/scripts.vim 2901.355 2805.314 2805.314: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftplugin/fish.vim 2902.246 000.050 000.050: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/indent/fish.vim 2902.771 000.169 000.169: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/syntax/fish.vim 2905.582 000.294 000.294: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/autoload/remote/host.vim 2906.201 000.193 000.193: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim 2907.541 010.630: opening buffers 2907.599 000.058: BufEnter autocommands 2907.605 000.006: editing files in windows 2908.033 000.427: VimEnter autocommands 2908.035 000.002: before starting main loop 2913.764 005.729: first screen update 2913.767 000.003: --- NVIM STARTED --- $
babakness commented 7 years ago

Mind blowingly slow for me, wow. Any direction on how to improve the load time?

gmile commented 7 years ago

@babakness can you run vim with --startuptime flag like this:

vim --startuptime vim.log some_file.txt

And post here the contents of vim.log?

In my case I have solved the problem after I noticed incorrectly configured fish, specifically the usage of fish_user_paths fish's function.

babakness commented 7 years ago

@gmile Sure, relevant bits here:

065.290  000.046: setting raw mode
065.294  000.004: start termcap
065.313  000.019: clearing screen
074.441  001.215  001.215: sourcing /usr/local/share/vim/vim80/scripts.vim
5024.670  4950.498  4950.498: sourcing /Users/me/.vim/bundle/vim-fish/ftplugin/fish.vim
5025.775  000.068  000.068: sourcing /Users/me/.vim/bundle/vim-fish/indent/fish.vim
5026.555  000.195  000.195: sourcing /Users/me/.vim/bundle/vim-fish/syntax/fish.vim
5027.115  010.826: opening buffers
5027.171  000.056: BufEnter autocommands
5027.176  000.005: editing files in windows
5027.498  000.322: VimEnter autocommands
5027.499  000.001: before starting main loop
5028.096  000.597: first screen update
5028.097  000.001: --- VIM STARTED ---
babakness commented 7 years ago

similar issue with nvim. Both installed via brew on mac.

gmile commented 7 years ago

@babakness can you run this:

fish -p profile.txt -c 'echo "Hello, world!"'

And post the contents of profile.txt?

mpcsh commented 6 years ago

I'm just starting out with fish and I had this problem too. My config.fish only had the following line:

brew command command-not-found-init > /dev/null 2>&1; and . (brew command-not-found-init)

Removing it caused vim-fish to launch smoothly.

avegancafe commented 6 years ago

Talk about specific lol. That seems unrelated to this plugin, I wanna say...

avegancafe commented 6 years ago

I'm closing this, as I've had my issue solved. Thank you @ElijahLynn !

dag commented 6 years ago

Reopening because others reported slowness as well, but didn't report it being solved.

I would guess the slowness comes either from executable() having to search all of $PATH, although that should still be pretty much instant, it happens any time you type an unknown command into the shell; or from calling out to fish with system() to get $fish_function_path, which will run all your fish config.

Those of you experiencing slowness: is fish itself similarly slow to start?

gmile commented 6 years ago

Just a 5 cents: it is very likely that people use fish_user_path incorrectly. I've ran into this very problem and solved it by reading more about how to use fish_user_path.

When in need to add something to path, instead of doing this (which I did and which was wrong):

set fish_user_paths $fish_user_paths /new/path

One must do this:

set fish_user_paths /new/path
set fish_user_paths /new/path /another/new/path /and/another/one

fishshell listens for changes to $fish_user_paths variable, and does what has to be done to update $PATH.

I recognized this specifically by running benchmarks built into vim and fish, and inspecting the output. In my case there were tons and tons of fish_user_paths calls. Here's how to benchmark:

dag commented 6 years ago

Hmm, fish_function_path is not the same as fish_user_paths.

gmile commented 6 years ago

@dag good point, I mistyped that! Updated the comment to have fish_function_path removed. Thank you for spotting!

dag commented 6 years ago

Ah you mean, this might be causing executable() to be slow for people? I thought you were saying it was making the system() call slow, but that you were confusing the issue.

gmile commented 6 years ago

Yes, I think it is executable() that's slow for people. It was for me.

ypresto commented 6 years ago

I found system("fish -c 'echo $fish_function_path'") is slow, but still calling fish -c 'echo $fish_function_path from shell is not slow.

dag commented 6 years ago

@ypresto Have you tried the suggestion at the bottom of the readme?

Also, have you tried calling that fish -c line from a shell other than fish?

squattingmonk commented 6 years ago

I had uninstalled this plugin due to the same issue. However, I had also been noticing that the startup time for fish shell itself was getting longer and longer. I found that I was incorrectly setting fish_user_paths as as @gmile had mentioned. This was causing the variable to bloat over time (tens of thousands of directories long). Removing this and then re-installing the plugin seems to have fixed both issues.

ypresto commented 6 years ago

@dag Thanks, set shell=sh resolved my issue..! Moreover, start up time of entire vim got faster! (echo &shell was /bin/zsh).

ypresto commented 6 years ago

hmm, I found it is still slow when I put anyenv init code in config.fish:

eval (anyenv init - fish | source)

When I put sleep 5 it tooks 5 secs to open config.fish file with vim.

chemzqm commented 5 years ago

There is job for vim & neovim could be used to avoid the block running system command.

zdcthomas commented 5 years ago

I'm definitely still experiencing slowness. After profiling, I was able to narrow down the problem to ftplugin but beyond that, I'm not sure. I've also tried the suggestion of set shell=sh which sped up vim in general but didn't make much of a difference to vim-fish startup time. As a side note, is this repo still being maintained? I'd love to help with it in any way I can

jooize commented 4 years ago

Takes 3 seconds longer to start Neovim when opening a file of filetype fish with vim-fish enabled. Instant when starting same configuration from Zsh or Bash, so let me see….

In my case it seems to be because my Fish is slow at startup (because of something in my configuration, apparently), and Fish is for some reason called by vim-fish even when I specify set shell=sh in Neovim's init.vim as the top to be sure it has an effect on plugins.

Workaround (with reduced functionality): I commented out every system() and execute in $HOME/.local/share/dein/repos/github.com/dag/vim-fish/*/*, then fought the cache of Dein, somehow eventually successfully.

Solution (for me): Clean up $fish_user_paths and properly set it (if at all). https://github.com/fish-shell/fish-shell/issues/5834#issuecomment-633265485 Edit $XDG_CONFIG_HOME/fish/config.fish and make changes according with comments, then erase all of $fish_user_paths by running set --erase --universal fish_user_paths and then restart Fish.

blankname commented 4 years ago

@jooize

vim-fish always calls fish to get the value of $fish_function_path on startup.

I attempted @chemzqm's suggestion if you'd like to try it out: blankname/vim-fish/pull/3

If all of the cases of this slowness are traced to misconfiguration of fish, I probably won't merge it.

jooize commented 4 years ago

Is there any chance running the job in the background results in undesired behavior?

blankname commented 4 years ago

If something uses path before the job has finished it won't contain the $fish_function_path directories.

Vim's docs have some things that use path listed: image

Plugins may also use path.

The worry is that this change might be added complication to solve a problem that's better solved outside of vim through fish configuration fixes.

jooize commented 4 years ago

It seems the reason we're evaluating job_start should be solved without it. Asynchronous startup can be a worthy pursuit, but in this case I agree that it appears worse to make that change.

I actually hadn't fixed my problem with $fish_user_paths, but learned how with some help over at https://github.com/fish-shell/fish-shell/issues/5834#issuecomment-633267311.

Thank you for your time, @blankname.

lamchau commented 4 years ago

my performance issues ended up being a misconfigured $fish_user_paths in my config.fish.

simple fix for me was to do the following:

set --universal fish_user_paths $updated_paths