Skip to content

Commit

Permalink
Make sure vim-misc is installed, politely complain if it isn't
Browse files Browse the repository at this point in the history
See issue #65 on GitHub and numerous other issues before it:
  #65
  • Loading branch information
xolox committed Jul 3, 2013
1 parent d5c3b6a commit 70c89aa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -236,7 +236,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 June 24, 2013 at 23:47.
1 Vim scripts on July 4, 2013 at 00:27.

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

Expand Down
4 changes: 2 additions & 2 deletions autoload/xolox/session.vim
@@ -1,10 +1,10 @@
" Public API for the vim-notes plug-in.
"
" Author: Peter Odding
" Last Change: June 24, 2013
" Last Change: July 4, 2013
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '2.4.4'
let g:xolox#session#version = '2.4.5'

" Public API for session persistence. {{{1

Expand Down
2 changes: 1 addition & 1 deletion doc/session.txt
Expand Up @@ -477,7 +477,7 @@ might take a while...)
Function reference ~

The documentation of the 34 functions below was extracted from 1 Vim scripts on
June 24, 2013 at 23:47.
July 4, 2013 at 00:27.

-------------------------------------------------------------------------------
*session-public-api-for-vim-notes-plug-in*
Expand Down
34 changes: 29 additions & 5 deletions plugin/session.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding
" Last Change: May 12, 2013
" Last Change: July 4, 2013
" URL: http://peterodding.com/code/vim/session/

" Support for automatic update using the GLVS plug-in.
Expand All @@ -11,6 +11,22 @@ if &cp || exists('g:loaded_session')
finish
endif

" Make sure vim-misc is installed. {{{1

try
" The point of this code is to do something completely innocent while making
" sure the vim-misc plug-in is installed. We specifically don't use Vim's
" exists() function because it doesn't load auto-load scripts that haven't
" already been loaded yet (last tested on Vim 7.3).
call type(g:xolox#misc#version)
catch
echomsg "Warning: The vim-session plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-session plug-in will now be disabled."
let g:loaded_session = 1
finish
endtry

" Configuration defaults. {{{1

" The name of the default session (without directory or filename extension).
if !exists('g:session_default_name')
let g:session_default_name = 'default'
Expand Down Expand Up @@ -82,7 +98,8 @@ if !exists('g:session_command_aliases')
let g:session_command_aliases = 0
endif

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

let s:directory = fnamemodify(g:session_directory, ':p')
if !isdirectory(s:directory)
call mkdir(s:directory, 'p')
Expand All @@ -95,7 +112,8 @@ if filewritable(s:directory) != 2
endif
unlet s:directory

" Define menu items to make the plug-in more accessible.
" Menu items to make the plug-in more accessible. {{{1

amenu 400.10 &Sessions.&Open\ session\.\.\.<Tab>:OpenSession :OpenSession<CR>
amenu 400.20 &Sessions.&Save\ session\.\.\.<Tab>:SaveSession :SaveSession<CR>
amenu 400.30 &Sessions.&Close\ session\.\.\.<Tab>:CloseSession :CloseSession<CR>
Expand All @@ -109,7 +127,8 @@ amenu 400.100 &Sessions.Close\ tab\ session\.\.\.<Tab>:CloseTabSession :CloseTab
amenu 400.110 &Sessions.-Sep2- :
amenu 400.120 &Sessions.&Restart\ Vim\.\.\.<Tab>:RestartVim :RestartVim<CR>

" Define automatic commands for automatic session management.
" Automatic commands for automatic session management. {{{1

augroup PluginSession
autocmd!
au VimEnter * nested call xolox#session#auto_load()
Expand All @@ -118,6 +137,8 @@ augroup PluginSession
au VimLeavePre * call xolox#session#auto_unlock()
augroup END

" Plug-in commands (user defined commands). {{{1

" Define commands that enable users to manage multiple named, heavy-weight
" sessions (used to persist/restore a complete Vim editing session including
" one or more tab pages).
Expand All @@ -137,6 +158,8 @@ command! -bar -bang CloseTabSession call xolox#session#close_tab_cmd(<q-bang>, '
" Define a command to restart Vim editing sessions.
command! -bang -nargs=* -complete=command RestartVim call xolox#session#restart_cmd(<q-bang>, <q-args>)

" Plug-in command aliases. {{{2

if g:session_command_aliases
" Define command aliases of the form "Session" + Action in addition to
" the real command names which are of the form Action + "Session" (above).
Expand All @@ -151,7 +174,8 @@ if g:session_command_aliases
command! -bar -bang SessionTabClose call xolox#session#close_tab_cmd(<q-bang>, 'SessionTabClose')
endif

" Don't reload the plug-in once it has loaded successfully.
" Don't reload the plug-in once it has loaded successfully. {{{1

let g:loaded_session = 1

" vim: ts=2 sw=2 et

0 comments on commit 70c89aa

Please sign in to comment.