junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.5k stars 115 forks source link

Some problems with tmux and Airline #15

Closed xautjzd closed 10 years ago

xautjzd commented 10 years ago

First, thanks for goyo.Today, I installed goyo using vundle plugin.and have configured vimrc as follows:

function! g:goyo_before()
  silent !tmux set status off
endfunction

function! g:goyo_after()
  silent !tmux set status on
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

but when I exit Goyo,get the error messages:

Error detected while processing function <SNR>56_blank..<SNR>56_goyo_off:
line   50:
E492: Not an editor command:     AirlineRefreshset option: status -> on

Press ENTER or type command to continue

after I type any command, my status bar looks like this: workspace 1_025

before adding Goyo,it looks like as follows: workspace 1_026

junegunn commented 10 years ago

Hi, does your Vim have :AirlineRefresh command? Does it work? If there's no such command, it is possible that you're running an old version of vim-airline. Try :BundleUpdate to update airline and see if it works.

xautjzd commented 10 years ago

@junegunn Thanks for your answer. There is really not :AirlineRresh command, when I updated my plugins, It works .Thanks again

xautjzd commented 10 years ago

@junegunn There is another problem: when I redefine goyo_before and goyo_after function and make it local to script, it will display such errors:

Error detected while processing function <SNR>56_goyo..<SNR>56_goyo_on:
line 99:
E117: Unknown function: s:goyo_before

and quit Goyo, it will display the errors as follows:

Error detected while processing function <SNR>56_blank..<SNR>56_goyo_off:
line 67:
E117: Unknown function: s:goyo_after

but when I make them global like this:

function! g:goyo_before()                                                                                      
     silent !tmux set status off                                                                                
 endfunction                                                                                                    

 function! g:goyo_after()                                                                                       
     silent !tmux set status on                                                                                 
 endfunction                                                                                                    

 let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

it will be OK.

junegunn commented 10 years ago

Thanks. Actually I'm aware of the problem. And It depends on the version of Vim. I've noticed that function(s:something) doesn't work on some old versions of Vim. Maybe I should just update the example not to confuse the users who don't run the recent version.

xautjzd commented 10 years ago

@junegunn my Vim version is 7.3.682. What version do you use? version 7.4?

xautjzd commented 10 years ago

I'm confused about silent! AirlineRefresh and silent !tmux set status on. Does the key word silent mean showing no message when executing method, no matter it's Ok or wrong? why is the former ! nearer to silent and the latter ! nearer to tmux? Are they different?

junegunn commented 10 years ago

my Vim version is 7.3.682. What version do you use? version 7.4?

I'm running 7.4.27 and have no problem with script-local funcrefs, but I can confirm that it doesn't work on 7.3.429 which I have on another machine. I'm not sure which is the first version that officially supported the feature.

why is the former ! nearer to silent and the latter ! nearer to tmux? Are they different?

silent suppresses normal messages. The bang version, silent! even ignores error messages. For more information, you can refer to :help silent. I've added silent! to AirlineRefresh to ignore error even when the user is running an old airline without the command.