Skip to content

Commit 94cc679

Browse files
committed
Make the plug-in compatible with system wide installation
1 parent 623bb04 commit 94cc679

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

autoload/xolox/notes.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.16.4'
9+
let g:xolox#notes#version = '0.16.5'
1010

1111
function! xolox#notes#shortcut() " {{{1
1212
" The "note:" pseudo protocol is just a shortcut for the :Note command.

plugin/notes.vim

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,38 @@ if &cp || exists('g:loaded_notes')
1111
finish
1212
endif
1313

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)