From dd2664e32b772b01046ffdb4ea68fc86a75e8aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Sat, 7 Mar 2015 17:18:36 +0100
Subject: [PATCH] Support for various runtime files

* viminfo
* backups
* swap files
* undo files
---
 cfg/09-file-options.vim  |  4 ++++
 cfg/10-runtime-files.vim | 41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 cfg/09-file-options.vim
 create mode 100644 cfg/10-runtime-files.vim

diff --git a/cfg/09-file-options.vim b/cfg/09-file-options.vim
new file mode 100644
index 0000000..1b3841a
--- /dev/null
+++ b/cfg/09-file-options.vim
@@ -0,0 +1,4 @@
+" By default, keep undo history and use swap files, but don't use backups.
+set undofile
+set swapfile
+set nobackup
diff --git a/cfg/10-runtime-files.vim b/cfg/10-runtime-files.vim
new file mode 100644
index 0000000..732cf55
--- /dev/null
+++ b/cfg/10-runtime-files.vim
@@ -0,0 +1,41 @@
+" viminfo file
+if &g:viminfo !~ ",n"
+	let s:viminfo_path = GetVardataPath( "viminfo" )
+	let &g:viminfo = &g:viminfo . ",n" . s:viminfo_path
+	if filereadable( s:viminfo_path )
+		rviminfo
+	endif
+endif
+
+" Undo file, if active
+if &g:undofile
+	let s:undo_path = GetVardataPath( "undo" )
+	if CreateDirectoryIfNecessary( s:undo_path )
+		let &g:undodir = s:undo_path
+	else
+		echoerr "could not create " . s:undo_path
+		set noundodir
+	endif
+endif
+
+" Swap directory
+if &g:swapfile
+	let s:swap_path = GetVardataPath( "swap" )
+	if CreateDirectoryIfNecessary( s:swap_path )
+		let &g:directory = s:swap_path
+	else
+		echoerr "could not create " . s:swap_path
+		set noswapfile
+	endif
+endif
+
+" Backup directory
+if &g:backup
+	let s:backup_path = GetVardataPath( "backup" )
+	if CreateDirectoryIfNecessary( s:backup_path )
+		let &g:backupdir = s:backup_path
+	else
+		echoerr "could not create " . s:backup_path
+		set nobackup
+	endif
+endif