asyncrun.vim icon indicating copy to clipboard operation
asyncrun.vim copied to clipboard

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

Open jshort opened this issue 7 years ago • 8 comments

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 avatar Nov 15 '17 23:11 jshort

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 avatar Nov 16 '17 00:11 jshort

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}'])

jshort avatar Nov 16 '17 18:11 jshort

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'

skywind3000 avatar Nov 17 '17 04:11 skywind3000

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

Jomik avatar Mar 18 '18 14:03 Jomik

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()}%)

Konfekt avatar Apr 16 '18 10:04 Konfekt

Tested all recommendations, but no one works for me.

Shatur avatar Mar 12 '20 12:03 Shatur

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?.

Konfekt avatar Mar 12 '20 13:03 Konfekt

It worked, thank you!

Shatur avatar Mar 12 '20 13:03 Shatur