X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/39d7f74f37c473160306e750a3e0f95ea27c65d5..d2204ed1a0eb3ea915d866ba10b7e36481774f9f:/etc/vim/.vimrc?ds=inline diff --git a/etc/vim/.vimrc b/etc/vim/.vimrc index 6ad6135..0b9bcd9 100644 --- a/etc/vim/.vimrc +++ b/etc/vim/.vimrc @@ -48,6 +48,7 @@ endif unlet x unlet y + """ vim-only defaults if !has('nvim') " neovim defaults are already set @@ -57,15 +58,16 @@ if !has('nvim') autocmd! vimStartup " packages - packadd! matchit - packadd! editorconfig " this is now built to [n]vim in but optional - packadd! vim-commentary " nvim has built in commenting now + packadd! matchit " included with [n]vim but disabled by default + packadd! editorconfig " now included with [n]vim but disabled by default + packadd! vim-commentary " nvim has this built in now, vim still needs it " options set hlsearch autocmd BufRead * set autoindent endif + """ styling " nice default theme colorscheme murphy @@ -77,10 +79,10 @@ autocmd VimEnter,WinNew * set cursorline " unique highlighting for leading spaces and in-line spaces " NOTE: this leaves tabs and other special whitespace untouched intentionally -autocmd VimEnter,ColorScheme * highlight Space ctermfg=Grey guifg=#686868 -autocmd VimEnter,ColorScheme * highlight link SpaceLeading NonText -autocmd VimEnter,WinNew * match Space / / -autocmd VimEnter,WinNew * 2match SpaceLeading /\(^ \+\)\|\( \+$\)/ +autocmd VimEnter,ColorScheme * highlight SpaceInner ctermfg=Grey guifg=#686868 +autocmd VimEnter,ColorScheme * highlight link SpaceOuter NonText +autocmd VimEnter,WinNew * match SpaceInner / / +autocmd VimEnter,WinNew * 2match SpaceOuter /\(^ \+\)\|\( \+$\)/ " always show statusline set laststatus=2 @@ -113,9 +115,15 @@ autocmd VimEnter,WinNew, autocmd VimEnter,WinNew * set list set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■ + """ editor " always save undo file for all file buffers -autocmd BufRead * set undofile +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 +set nomodelineexpr "" indent " always use shiftwidth instead of tabsize @@ -129,7 +137,7 @@ autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab let g:EditorConfig_enable_for_new_buf = 1 "" syntax -autocmd FileType todo set colorcolumn=0 +autocmd Syntax php syn clear phpHereDoc phpNowDoc "" mappings " use more accessible escapes, as C-n and C-o are shadowed by some terminals @@ -165,3 +173,98 @@ nnoremap l if !has('nvim') && maparg('', 'n') ==# '' nnoremap :nohlsearch=has('diff')?'diffupdate':'' 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_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_swapfile') && b:sev_suda_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