From e5668602cc89f3298a1ab936b082e82519aa6a50 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 30 Dec 2020 09:58:20 +0100 Subject: Enable again swapfiles, fixes #638 --- ftdetect/polyglot.vim | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 4d6935fe..29a4a2c7 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -2687,8 +2687,25 @@ if !has_key(g:polyglot_is_disabled, 'sensible') " Reload unchanged files automatically. set autoread - " Disable swap, it doesn't play well with autoread - set noswapfile + " This is needed to avoid swapfile warning when auto-reloading + set shortmess+=A + + " Avoids swapfiles in current directory + if &directory =~# '^\.,' + if !empty($HOME) + if has('win32') + let &directory = expand('$HOME/vimfiles') . '//,' . &directory + else + let &directory = expand('$HOME/.vim') . '//,' . &directory + endif + endif + if !empty($XDG_DATA_HOME) + let &directory = expand('$XDG_DATA_HOME') . '//,' . &directory + endif + if has('macunix') + let &directory = expand('$HOME/Library/Autosave Information') . '//,' . &directory + endif + endif " Autoindent when starting new line, or using `o` or `O`. set autoindent -- cgit v1.2.3