Skip to content

Commit 407ce08

Browse files
committed
Merge pull request #78: Make color scheme persistence configurable
Related comments/issues/pull requests: - #6 (comment) - #78 - #96
2 parents cf412a9 + 48c00ff commit 407ce08

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ The session load/save prompts are quite verbose by default because they explain
161161

162162
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'`.
163163

164+
### The `g:session_persist_colors` option
165+
166+
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]:
167+
168+
:let g:session_persist_colors = 0
169+
164170
### The `g:session_persist_globals` option
165171

166172
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).
@@ -246,7 +252,7 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac
246252
<!-- Start of generated documentation -->
247253

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

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

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

556562

563+
[bg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'background'
557564
[delcommand]: http://vimdoc.sourceforge.net/htmldoc/map.html#:delcommand
558565
[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip
559566
[download-session]: http://peterodding.com/code/vim/downloads/session.zip

autoload/xolox/session.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
" Last Change: July 6, 2014
55
" URL: http://peterodding.com/code/vim/session/
66

7-
let g:xolox#session#version = '2.4.15'
7+
let g:xolox#session#version = '2.5'
88

99
" Public API for session persistence. {{{1
1010

@@ -45,14 +45,14 @@ function! xolox#session#save_session(commands, filename) " {{{2
4545
call xolox#session#save_globals(a:commands)
4646
if is_all_tabs
4747
call xolox#session#save_features(a:commands)
48-
call xolox#session#save_colors(a:commands)
48+
if g:session_persist_colors
49+
call xolox#session#save_colors(a:commands)
50+
endif
4951
endif
5052
call xolox#session#save_qflist(a:commands)
5153
call xolox#session#save_state(a:commands)
5254
if is_all_tabs
5355
call xolox#session#save_fullscreen(a:commands)
54-
endif
55-
if is_all_tabs
5656
call add(a:commands, 'doautoall SessionLoadPost')
5757
else
5858
call add(a:commands, 'let s:winrestcmd = winrestcmd()')

doc/session.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ Contents ~
2828
8. The |g:session_autosave_periodic| option
2929
9. The |g:session_verbose_messages| option
3030
10. The |g:session_default_to_last| option
31-
11. The |g:session_persist_globals| option
32-
12. The |g:session_restart_environment| option
33-
13. The |g:session_command_aliases| option
34-
14. The |g:session_menu| option
35-
15. The |g:loaded_session| option
31+
11. The |g:session_persist_colors| option
32+
12. The |g:session_persist_globals| option
33+
13. The |g:session_restart_environment| option
34+
14. The |g:session_command_aliases| option
35+
15. The |g:session_menu| option
36+
16. The |g:loaded_session| option
3637
5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins|
3738
6. Known issues |session-known-issues|
3839
7. Function reference |session-function-reference|
@@ -363,6 +364,15 @@ instead of the default session. Note that the session plug-in will still show
363364
you the dialog asking whether you want to restore the last used session. To get
364365
rid of the dialog you have to set |g:session_autoload| to "'yes'".
365366

367+
-------------------------------------------------------------------------------
368+
The *g:session_persist_colors* option
369+
370+
By default the plug-in will save the color scheme and the |'background'| option
371+
with the session to be reused the next time that session is loaded, this can be
372+
disabled by adding the following line to your |vimrc| script:
373+
>
374+
:let g:session_persist_colors = 0
375+
<
366376
-------------------------------------------------------------------------------
367377
The *g:session_persist_globals* option
368378

@@ -490,7 +500,7 @@ might take a while...)
490500
Function reference ~
491501

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

495505
-------------------------------------------------------------------------------
496506
*public-api-for-vim-session-plug-in*

plugin/session.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim script
22
" Author: Peter Odding
3-
" Last Change: June 22, 2014
3+
" Last Change: July 6, 2014
44
" URL: http://peterodding.com/code/vim/session/
55

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

112+
" Toggle the persistence of color schemes and the 'background' option.
113+
if !exists('g:session_persist_colors')
114+
let g:session_persist_colors = 1
115+
endif
116+
112117
" Make sure the sessions directory exists and is writable. {{{1
113118

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

0 commit comments

Comments
 (0)