]> git.sev.monster Git - dotfiles.git/blobdiff - etc/vim/.vimrc
vimrc: suda settings can be buffer-local now
[dotfiles.git] / etc / vim / .vimrc
index 888e18967957aee030f3ca5d333757b70f715366..b59d19e4f9bb37e2818d75376c40e958c722d98c 100644 (file)
@@ -68,42 +68,6 @@ if !has('nvim')
 endif
 
 
-""" package config
-"" suda
-" https://github.com/lambdalisue/vim-suda/issues/32#issuecomment-829608925
-if ! &diff
-    let g:suda_smart_edit = 1
-endif
-" re-enable backup, swap, undo for suda buffers that we can read
-" https://github.com/lambdalisue/vim-suda/issues/25
-function s:SudaSettingsSave()
-    let l:f = expand('<afile>')
-    if stridx(l:f, 'suda://') == 0
-        let g:sev_suda_file = expand('<afile>')
-        let g:sev_suda_backup = &backup
-        let g:sev_suda_swapfile = &swapfile
-        let g:sev_suda_undofile = &undofile
-    endif
-endfunction
-function s:SudaSettingsRestore()
-    if exists('g:sev_suda_file') && filereadable(g:sev_suda_file)
-        if exists('g:sev_suda_backup') && g:sev_suda_backup
-            " XXX: suda.vim uses setlocal for this, even though it's global...
-            "      https://github.com/lambdalisue/vim-suda/issues/85
-            setlocal backup
-        endif
-        if exists('g:sev_suda_swapfile') && g:sev_suda_swapfile
-            setlocal swapfile
-        endif
-        if exists('g:sev_suda_undofile') && g:sev_suda_undofile
-            setlocal undofile
-        endif
-    endif
-endfunction
-autocmd BufReadPre * call s:SudaSettingsSave()
-autocmd BufReadPost suda://* call s:SudaSettingsRestore()
-
-
 """ styling
 " nice default theme
 colorscheme murphy
@@ -156,7 +120,6 @@ set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■
 " always save undo file for all file buffers
 autocmd BufReadPre * setlocal undofile
 
-
 " explicitly use modeline, even on systems where it's disabled by system vimrc
 autocmd BufRead * set modeline
 " should be default disabled but just in case
@@ -210,3 +173,35 @@ nnoremap <A-l> <C-w>l
 if !has('nvim') && maparg('<C-L>', 'n') ==# ''
   nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
 endif
+
+
+""" package config
+"" suda
+" https://github.com/lambdalisue/vim-suda/issues/32#issuecomment-829608925
+if ! &diff
+    let g:suda_smart_edit = 1
+endif
+" re-enable backup, swap, undo for suda buffers that we can read
+" https://github.com/lambdalisue/vim-suda/issues/25
+function s:SudaSettingsSave()
+    let b:sev_suda_backup = &backup
+    let b:sev_suda_swapfile = &swapfile
+    let b:sev_suda_undofile = &undofile
+endfunction
+function s:SudaSettingsRestore()
+    if filereadable(expand('<afile>')[7:])
+        if exists('b:sev_suda_backup') && b:sev_suda_backup
+            " XXX: suda.vim uses setlocal for this, even though it's global...
+            "      https://github.com/lambdalisue/vim-suda/issues/85
+            setlocal backup
+        endif
+        if exists('b:sev_suda_swapfile') && b:sev_suda_swapfile
+            setlocal swapfile
+        endif
+        if exists('b:sev_suda_undofile') && b:sev_suda_undofile
+            setlocal undofile
+        endif
+    endif
+endfunction
+autocmd BufReadPre suda://* call s:SudaSettingsSave()
+autocmd BufReadPost suda://* call s:SudaSettingsRestore()
This page took 0.047056 seconds and 4 git commands to generate.