Skip to content

Commit

Permalink
Make the plug-in compatible with system wide installation
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 25, 2011
1 parent 623bb04 commit 94cc679
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion autoload/xolox/notes.vim
Expand Up @@ -6,7 +6,7 @@
" Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently.

let g:xolox#notes#version = '0.16.4'
let g:xolox#notes#version = '0.16.5'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down
25 changes: 18 additions & 7 deletions plugin/notes.vim
Expand Up @@ -11,27 +11,38 @@ if &cp || exists('g:loaded_notes')
finish
endif

" Make sure the default paths below are compatible with Pathogen.
let s:plugindir = expand('<sfile>:p:h') . '/../misc/notes'
" This is a bit tricky: We want to be compatible with Pathogen which installs
" plug-ins as "bundles" under ~/.vim/bundle/*/ so we use a relative path to
" make sure we 'stay inside the bundle'. However if the notes.vim plug-in is
" installed system wide the user probably won't have permission to write
" inside the installation directory, so we have to switch to $HOME then.
let s:systemdir = xolox#misc#path#absolute(expand('<sfile>:p:h') . '/../misc/notes')
if filewritable(s:systemdir) == 2
let s:localdir = s:systemdir
elseif xolox#misc#os#is_win()
let s:localdir = xolox#misc#path#absolute('~/vimfiles/misc/notes')
else
let s:localdir = xolox#misc#path#absolute('~/.vim/misc/notes')
endif

" Define the default location where the user's notes are saved?
if !exists('g:notes_directory')
let g:notes_directory = s:plugindir . '/user'
let g:notes_directory = xolox#misc#path#merge(s:localdir, 'user')
endif

" Define the default location of the shadow directory with predefined notes?
if !exists('g:notes_shadowdir')
let g:notes_shadowdir = s:plugindir . '/shadow'
let g:notes_shadowdir = xolox#misc#path#merge(s:systemdir, 'shadow')
endif

" Define the default location for the full text index.
if !exists('g:notes_indexfile')
let g:notes_indexfile = s:plugindir . '/index.pickle'
let g:notes_indexfile = xolox#misc#path#merge(s:localdir, 'index.pickle')
endif

" Define the default location for the keyword scanner script.
if !exists('g:notes_indexscript')
let g:notes_indexscript = s:plugindir . '/search-notes.py'
let g:notes_indexscript = xolox#misc#path#merge(s:systemdir, 'search-notes.py')
endif

" Define the default suffix for note filenames.
Expand All @@ -41,7 +52,7 @@ endif

" Define the default location for the tag name index (used for completion).
if !exists('g:notes_tagsindex')
let g:notes_tagsindex = s:plugindir . '/tags.txt'
let g:notes_tagsindex = xolox#misc#path#merge(s:localdir, 'tags.txt')
endif

" Define the default action when a note's filename and title are out of sync.
Expand Down

0 comments on commit 94cc679

Please sign in to comment.