Skip to content

Commit

Permalink
Merge pull request #78: Make color scheme persistence configurable
Browse files Browse the repository at this point in the history
Related comments/issues/pull requests:
 - #6 (comment)
 - #78
 - #96
  • Loading branch information
xolox committed Jul 6, 2014
2 parents cf412a9 + 48c00ff commit 407ce08
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -161,6 +161,12 @@ The session load/save prompts are quite verbose by default because they explain

By default this option is set to false (0). When you set this option to true (1) and you start Vim, the session plug-in will open your last used session instead of the default session. Note that the session plug-in will still show you the dialog asking whether you want to restore the last used session. To get rid of the dialog you have to set `g:session_autoload` to `'yes'`.

### The `g:session_persist_colors` option

By default the plug-in will save the color scheme and the ['background' option] [bg] with the session to be reused the next time that session is loaded, this can be disabled by adding the following line to your [vimrc script] [vimrc]:

:let g:session_persist_colors = 0

### The `g:session_persist_globals` option

The vim-session plug-in uses Vim's [:mksession] [mksession] command but it changes ['sessionoptions'][sessionoptions] so that Vim options and mappings are not persisted. The plug-in does this because persistence of options and mappings can break loading of sessions, in other words it's fragile (in my opinion).
Expand Down Expand Up @@ -246,7 +252,7 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac
<!-- Start of generated documentation -->

The documentation of the 34 functions below was extracted from
1 Vim scripts on July 6, 2014 at 20:47.
1 Vim scripts on July 6, 2014 at 21:01.

### Public API for the vim-session plug-in

Expand Down Expand Up @@ -554,6 +560,7 @@ Here's an example session script generated by the vim-session plug-in while I wa
unlet SessionLoad


[bg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'background'
[delcommand]: http://vimdoc.sourceforge.net/htmldoc/map.html#:delcommand
[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip
[download-session]: http://peterodding.com/code/vim/downloads/session.zip
Expand Down
8 changes: 4 additions & 4 deletions autoload/xolox/session.vim
Expand Up @@ -4,7 +4,7 @@
" Last Change: July 6, 2014
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '2.4.15'
let g:xolox#session#version = '2.5'

" Public API for session persistence. {{{1

Expand Down Expand Up @@ -45,14 +45,14 @@ function! xolox#session#save_session(commands, filename) " {{{2
call xolox#session#save_globals(a:commands)
if is_all_tabs
call xolox#session#save_features(a:commands)
call xolox#session#save_colors(a:commands)
if g:session_persist_colors
call xolox#session#save_colors(a:commands)
endif
endif
call xolox#session#save_qflist(a:commands)
call xolox#session#save_state(a:commands)
if is_all_tabs
call xolox#session#save_fullscreen(a:commands)
endif
if is_all_tabs
call add(a:commands, 'doautoall SessionLoadPost')
else
call add(a:commands, 'let s:winrestcmd = winrestcmd()')
Expand Down
22 changes: 16 additions & 6 deletions doc/session.txt
Expand Up @@ -28,11 +28,12 @@ Contents ~
8. The |g:session_autosave_periodic| option
9. The |g:session_verbose_messages| option
10. The |g:session_default_to_last| option
11. The |g:session_persist_globals| option
12. The |g:session_restart_environment| option
13. The |g:session_command_aliases| option
14. The |g:session_menu| option
15. The |g:loaded_session| option
11. The |g:session_persist_colors| option
12. The |g:session_persist_globals| option
13. The |g:session_restart_environment| option
14. The |g:session_command_aliases| option
15. The |g:session_menu| option
16. The |g:loaded_session| option
5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins|
6. Known issues |session-known-issues|
7. Function reference |session-function-reference|
Expand Down Expand Up @@ -363,6 +364,15 @@ instead of the default session. Note that the session plug-in will still show
you the dialog asking whether you want to restore the last used session. To get
rid of the dialog you have to set |g:session_autoload| to "'yes'".

-------------------------------------------------------------------------------
The *g:session_persist_colors* option

By default the plug-in will save the color scheme and the |'background'| option
with the session to be reused the next time that session is loaded, this can be
disabled by adding the following line to your |vimrc| script:
>
:let g:session_persist_colors = 0
<
-------------------------------------------------------------------------------
The *g:session_persist_globals* option

Expand Down Expand Up @@ -490,7 +500,7 @@ might take a while...)
Function reference ~

The documentation of the 34 functions below was extracted from 1 Vim scripts on
July 6, 2014 at 20:47.
July 6, 2014 at 21:01.

-------------------------------------------------------------------------------
*public-api-for-vim-session-plug-in*
Expand Down
7 changes: 6 additions & 1 deletion plugin/session.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding
" Last Change: June 22, 2014
" Last Change: July 6, 2014
" URL: http://peterodding.com/code/vim/session/

" Support for automatic update using the GLVS plug-in.
Expand Down Expand Up @@ -109,6 +109,11 @@ if !exists('g:session_menu')
let g:session_menu = 1
endif

" Toggle the persistence of color schemes and the 'background' option.
if !exists('g:session_persist_colors')
let g:session_persist_colors = 1
endif

" Make sure the sessions directory exists and is writable. {{{1

let s:directory = fnamemodify(g:session_directory, ':p')
Expand Down

0 comments on commit 407ce08

Please sign in to comment.