Set correct AppData dir for more Windows versions

Replace the hard-coded path with an environment variable supported by
all versions of Windows since XP.
This commit is contained in:
Dan Grover
2013-03-09 00:54:26 -08:00
committed by Tim Pope
parent e7eda3bb86
commit 41499a5767
2 changed files with 3 additions and 3 deletions

View File

@@ -32,7 +32,7 @@ mostly `:set` calls.) Here's a taste:
* `'listchars'`: Makes `:set list` (visible whitespace) prettier. * `'listchars'`: Makes `:set list` (visible whitespace) prettier.
* `'scrolloff'`: Always show at least one line above/below the cursor. * `'scrolloff'`: Always show at least one line above/below the cursor.
* `'directory'`: Dump swap files under `~/.local/share/vim/swap`, * `'directory'`: Dump swap files under `~/.local/share/vim/swap`,
`~/Library/Vim/swap`, or `~\Application Data\Vim\swap`, depending on your `~/Library/Vim/swap`, or `%APPDATA%\Vim\swap`, depending on your
platform. Also `'backupdir'` and `'undodir'`. The directories aren't platform. Also `'backupdir'` and `'undodir'`. The directories aren't
created automatically, so try `mkdir -p ~/Library/Vim/{swap,backup,undo}`. created automatically, so try `mkdir -p ~/Library/Vim/{swap,backup,undo}`.
* `nmap Y y$`: Make `Y` behave like `C` and `D`. * `nmap Y y$`: Make `Y` behave like `C` and `D`.
@@ -74,7 +74,7 @@ don't like them strewn all over the file system, you have a few options.
* `~/.local/share/vim/undo` on Linux * `~/.local/share/vim/undo` on Linux
* `~/Library/Vim/undo` on OS X * `~/Library/Vim/undo` on OS X
* `~\Application Data\Vim\undo` on Windows * `%APPDATA%\Vim\undo` on Windows
2. Provide your own preferred location in `'undodir'`: 2. Provide your own preferred location in `'undodir'`:

View File

@@ -72,7 +72,7 @@ if !empty(&viminfo)
set viminfo^=! set viminfo^=!
endif endif
let s:dir = has('win32') ? '~/Application Data/Vim' : match(system('uname'), "Darwin") > -1 ? '~/Library/Vim' : empty($XDG_DATA_HOME) ? '~/.local/share/vim' : '$XDG_DATA_HOME/vim' let s:dir = has('win32') ? '$APPDATA/Vim' : match(system('uname'), "Darwin") > -1 ? '~/Library/Vim' : empty($XDG_DATA_HOME) ? '~/.local/share/vim' : '$XDG_DATA_HOME/vim'
if isdirectory(expand(s:dir)) if isdirectory(expand(s:dir))
if &directory =~# '^\.,' if &directory =~# '^\.,'
let &directory = expand(s:dir) . '/swap//,' . &directory let &directory = expand(s:dir) . '/swap//,' . &directory