X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/6cd24ad14f105d08d4519c25c652c03bbcc7a653..27a346435eaae9c38ce54dfdf899872b2cf6860d:/etc/vim/.vimrc diff --git a/etc/vim/.vimrc b/etc/vim/.vimrc index b59d19e..59c8b08 100644 --- a/etc/vim/.vimrc +++ b/etc/vim/.vimrc @@ -22,12 +22,10 @@ set backup backupcopy=yes " NOTE: neovim uses ShaDa (SHAred DAta) format for viminfo and swap, and uses a " different version of undo file, so these types of files when created by " vim cannot be used with neovim, and the 'viminfofile', 'directory', and -" 'undodir' directories cannot be shared. -" NOTE: neovim has a nice default for these directories and files so -" customizing them is not necessary for it. +" 'undodir' directories cannot be shared. since neovim has a nice default +" for these directories and files, customizing them is not necessary. if !has('nvim') " viminfo - " NOTE: 'viminfofile' is a deprecated alias for 'shada' in neovim execute 'set viminfofile='.x.'/.viminfo' " swap @@ -125,6 +123,9 @@ autocmd BufRead * set modeline " should be default disabled but just in case set nomodelineexpr +"" enable editorconfig parsing for new buffers +let g:EditorConfig_enable_for_new_buf = 1 + "" indent " always use shiftwidth instead of tabsize set smarttab @@ -134,7 +135,6 @@ autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab -let g:EditorConfig_enable_for_new_buf = 1 "" syntax autocmd Syntax php syn clear phpHereDoc phpNowDoc @@ -184,24 +184,87 @@ 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 + " fix https://github.com/lambdalisue/vim-suda/issues/87 + setlocal noswapfile endfunction function s:SudaSettingsRestore() if filereadable(expand('')[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 + try + setlocal swapfile + catch + " ignore swapfile errors, they should have been shown already + echohl ErrorMsg + for line in split(v:exception, '\n') + echomsg printf('[suda] %s', line) + endfor + echohl None + endtry endif if exists('b:sev_suda_undofile') && b:sev_suda_undofile setlocal undofile endif endif endfunction +function s:SudaProcessUndo(cmd) + let p = expand('')[7:] + if has('win32') || !&undofile || !filereadable(p) + return + endif + let p = resolve(p) + " XXX: comments are from :help backupdir to mark implementation details + let x = &undodir + " For backwards compatibility with Vim version 3.0 a '>' at the start + " of the option is removed. + if stridx(x, '>') == 0 + let x = x[1:] + endif + " To include a comma in a directory name precede it with a backslash. + for u in split(x, '\v\\@1