skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.86k stars 112 forks source link

vim-airline recommendation doesn't work with native package management #81

Open jshort opened 6 years ago

jshort commented 6 years ago

I just migrated my (neo)vim setup to use the native package management in 8.0/neovim. While the recommendation of:

let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])

Worked with pathogen, it is not working now:

Error detected while processing /Users/jwshort/.vimrc:
line   32:
E117: Unknown function: airline#section#create_right
E15: Invalid expression: airline#section#create_right(['%{g:asyncrun_status}'])

Same thing happens with both vim 8.0 path 1100 and neovim 0.2.1.

My vim-airline is working (other than this error section bit) so the plugin is loading.

jshort commented 6 years ago

RFD:

When Vim starts up, after processing your .vimrc, it scans all directories in
'packpath' for plugins under the "pack/*/start" directory.  First all those
directories are added to 'runtimepath'.  Then all the plugins are loaded.
See packload-two-steps for how these two steps can be useful.
jshort commented 6 years ago

Workaround (or suggestion for the wiki regarding vim-airline integration):

If you are using Vim 8.0 or Neovim native package management, plugins are loaded after vimrc is loaded and therefore calling airline#section#create_right will result in an Unknown function error. Instead use an autocmd:

autocmd VimEnter * let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
skywind3000 commented 6 years ago

I will look into it, before that, you can initialize g:asyncrun_status manually before airline#section#create_right by

let g:asyncrun_status = 'stopped'
Jomik commented 6 years ago

Alternative to this is to put airline in your opt directory, and then use packadd airline to load it in your .vimrc I am doing this for deoplete, using https://github.com/k-takata/minpac

Konfekt commented 6 years ago

Without any plug-in, by the following addition to vimrc, the status line shows in red letters when AsyncRun is running, and otherwise keeps quiet:

    function! AsyncRunStatline()
        if g:asyncrun_status is# 'running'
            return '[' . g:asyncrun_status . ']'
        else
            return ''
        endif
    endfunction
    set statusline+=%#warningmsg#
    set statusline+=%(%{AsyncRunStatline()}%)
Shatur commented 4 years ago

Tested all recommendations, but no one works for me.

Konfekt commented 4 years ago

https://github.com/skywind3000/asyncrun.vim/issues/81#issuecomment-381561455 might not have worked because the check fails if done before loading :AsyncRun. Please try again with it.

Other than that, perhaps something resets &statusline? To see what, type :verb set statusline?.

Shatur commented 4 years ago

It worked, thank you!