junegunn / limelight.vim

:flashlight: All the world's indeed a stage and we are merely players
MIT License
2.36k stars 54 forks source link

Dark background and colorscheme not preserved when toggling limelight off #11

Closed khughitt closed 9 years ago

khughitt commented 9 years ago

When toggling limelight on/off when using a dark theme, I noticed that the theme is not properly restored upon disabling limelight.

For example, using the vimrc file below, turning on limelight works fine, but turning it off results in a light theme, and requires one to both set the background to dark and reload the theme (e.g. hemisu) to restore it to the previous state.

~/.vimrc

set nocompatible
set runtimepath+=~/.vim/bundle/vim-hemisu
set runtimepath+=~/.vim/bundle/goyo.vim
set runtimepath+=~/.vim/bundle/limelight.vim

syntax on
set background=dark
colorscheme hemisu

function! GoyoBefore()
  Limelight
endfunction

function! GoyoAfter()
  Limelight!
endfunction

let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')]

nnoremap <leader><space> :Goyo<CR>

Any suggestions? I suppose I could save the theme and background state as variables and reload them after toggling Goyo off, but I thought I would check with you first in case there is a better upstream fix.

Vim version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  4 2015 08:02:36)
Included patches: 1-617
Compiled by Arch Linux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             -ebcdic          +localmap        +printer         +title
+arabic          +emacs_tags      +lua             +profile         +toolbar
+autocmd         +eval            +menu            +python          +user_commands
+balloon_eval    +ex_extra        +mksession       -python3         +vertsplit
+browse          +extra_search    +modify_fname    +quickfix        +virtualedit
++builtin_terms  +farsi           +mouse           +reltime         +visual
+byte_offset     +file_in_path    +mouseshape      +rightleft       +visualextra
+cindent         +find_in_path    +mouse_dec       +ruby            +viminfo
+clientserver    +float           +mouse_gpm       +scrollbind      +vreplace
+clipboard       +folding         -mouse_jsbterm   +signs           +wildignore
+cmdline_compl   -footer          +mouse_netterm   +smartindent     +wildmenu
+cmdline_hist    +fork()          +mouse_sgr       -sniff           +windows
+cmdline_info    +gettext         -mouse_sysmouse  +startuptime     +writebackup
+comments        -hangul_input    +mouse_urxvt     +statusline      +X11
+conceal         +iconv           +mouse_xterm     -sun_workshop    -xfontset
+cryptv          +insert_expand   +multi_byte      +syntax          +xim
+cscope          +jumplist        +multi_lang      +tag_binary      +xsmp_interact
+cursorbind      +keymap          -mzscheme        +tag_old_static  +xterm_clipboard
+cursorshape     +langmap         +netbeans_intg   -tag_any_white   -xterm_save
+dialog_con_gui  +libcall         +path_extra      -tcl             -xpm
+diff            +linebreak       +perl            +terminfo
+digraphs        +lispindent      +persistent_undo +termresponse
+dnd             +listcmds        +postscript      +textobjects
junegunn commented 9 years ago

Thanks for the detailed report. It looks like it's an issue of hemisu rather than a bug of Goyo or Limelight. If you check the value of &background after starting Vim with the attached vimrc, you'll notice that it's incorrectly set to light. So if you colorscheme hemisu again, then the light version will take place. (Goyo simply reloads the current color scheme on exit) This is not the case with the other color schemes, such as seoul256 which I use. You might want to file an issue on the issue tracker of hemisu. The current workaround is to force-reset color scheme in GoyoAfter function.

function! GoyoAfter()
  Limelight!
  set background=dark
  colorscheme hemisu
endfunction
khughitt commented 9 years ago

Thanks for the quick response and work-around! It looks like you are indeed correct and the issue lies with the hemisu theme. I will report it upstream. Thanks!