Skip to content

Commit b892cca

Browse files
committed
Option to set session filename extension (issue #22)
Issue #22 on GitHub: #22
1 parent 6a4af75 commit b892cca

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ Note that the session.vim plug-in automatically and unconditionally executes the
9393

9494
This option controls the location of your session scripts. Its default value is `~/.vim/sessions` (on UNIX) or `~\vimfiles\sessions` (on Windows). If you don't mind the default you don't have to do anything; the directory will be created for you. Note that a leading `~` is expanded to your current home directory (`$HOME` on UNIX, `%USERPROFILE%` on Windows).
9595

96+
### The `g:session_default_name` option
97+
98+
The name of the default session without directory or filename extension (you'll never guess what the default is).
99+
100+
### The `g:session_extension` option
101+
102+
The filename extension of session scripts. This should include the dot that separates the basename from the extension. Defaults to '.vim'.
103+
96104
### The `g:session_autoload` option
97105

98106
By default this option is set to `'prompt'`. This means that when you start Vim without opening any files and the `default` session script exists, the session plug-in will ask whether you want to restore your default session. When you set this option to `'yes'` and you start Vim without opening any files the default session will be restored without a prompt. To completely disable automatic loading you can set this option to `'no'`.

autoload/xolox/session.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.6.1'
6+
let g:xolox#session#version = '1.6.2'
77

88
call xolox#misc#compat#check('session', 2)
99

@@ -524,7 +524,7 @@ endfunction
524524

525525
function! xolox#session#name_to_path(name) " {{{2
526526
let directory = xolox#misc#path#absolute(g:session_directory)
527-
let filename = xolox#misc#path#encode(a:name) . '.vim'
527+
let filename = xolox#misc#path#encode(a:name) . g:session_extension
528528
return xolox#misc#path#merge(directory, filename)
529529
endfunction
530530

@@ -534,7 +534,7 @@ endfunction
534534

535535
function! xolox#session#get_names() " {{{2
536536
let directory = xolox#misc#path#absolute(g:session_directory)
537-
let filenames = split(glob(xolox#misc#path#merge(directory, '*.vim')), "\n")
537+
let filenames = split(glob(xolox#misc#path#merge(directory, '*' . g:session_extension)), "\n")
538538
return map(filenames, 'xolox#session#path_to_name(v:val)')
539539
endfunction
540540

doc/session.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ Contents ~
1616
4. Options |session-options|
1717
1. The |sessionoptions| setting
1818
2. The |g:session_directory| option
19-
3. The |g:session_autoload| option
20-
4. The |g:session_autosave| option
21-
5. The |g:session_default_to_last| option
22-
6. The |g:session_persist_globals| option
23-
7. The |g:session_restart_environment| option
24-
8. The |g:session_command_aliases| option
25-
9. The |g:loaded_session| option
19+
3. The |g:session_default_name| option
20+
4. The |g:session_extension| option
21+
5. The |g:session_autoload| option
22+
6. The |g:session_autosave| option
23+
7. The |g:session_default_to_last| option
24+
8. The |g:session_persist_globals| option
25+
9. The |g:session_restart_environment| option
26+
10. The |g:session_command_aliases| option
27+
11. The |g:loaded_session| option
2628
5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins|
2729
6. Known issues |session-known-issues|
2830
7. Contact |session-contact|
@@ -202,6 +204,18 @@ don't mind the default you don't have to do anything; the directory will be
202204
created for you. Note that a leading '~' is expanded to your current home
203205
directory ('$HOME' on UNIX, '%USERPROFILE%' on Windows).
204206

207+
-------------------------------------------------------------------------------
208+
The *g:session_default_name* option
209+
210+
The name of the default session without directory or filename extension
211+
(you'll never guess what the default is).
212+
213+
-------------------------------------------------------------------------------
214+
The *g:session_extension* option
215+
216+
The filename extension of session scripts. This should include the dot that
217+
separates the basename from the extension. Defaults to '.vim'.
218+
205219
-------------------------------------------------------------------------------
206220
The *g:session_autoload* option
207221

plugin/session.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ if !exists('g:session_default_name')
1616
let g:session_default_name = 'default'
1717
endif
1818

19+
" The file extension of session scripts.
20+
if !exists('g:session_extension')
21+
let g:session_extension = '.vim'
22+
endif
23+
1924
" When you start Vim without opening any files the plug-in will prompt you
2025
" whether you want to load the default session. Other supported values for
2126
" this option are 'yes' (to load the default session without prompting) and

0 commit comments

Comments
 (0)