-if !isdirectory($HOME . "/.local/share/vim")
- call mkdir($HOME . "/.local/share/vim", "p", 0700)
+let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim'
+if !isdirectory(x)
+ call mkdir(x, 'p', 0700)
+endif
+execute 'set viminfofile='.x.'/.viminfo'
+
+let y = x.'/swap'
+if !isdirectory(y)
+ call mkdir(y, 'p', 0700)
+endif
+execute 'set directory='.y.'//'
+
+let y = x.'/backup'
+if !isdirectory(y)
+ call mkdir(y, 'p', 0700)