+
+""" vim-only defaults
+if !has('nvim')
+ " neovim defaults are already set
+ source $VIMRUNTIME/defaults.vim
+
+ " disable jumping to last edit, we use vim-lastplace instead
+ autocmd! vimStartup
+
+ " packages
+ 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
+
+
+""" 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...
+ 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
+
+" always use color column with less intrusive colors
+autocmd VimEnter,WinNew * set colorcolumn=80
+" always use cursor line for better visibility
+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 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
+
+" truncate > lastline; lastline is nvim default, sensible.vim may also set it
+set display=truncate
+
+" more context while scrolling
+set scrolloff=5
+set sidescrolloff=8
+
+" show number column on all buffers
+autocmd VimEnter,WinNew * set number
+" use relative numbers in normal modes when focused, but not if number is off
+function! s:SetRelativeNumber(enable)
+ if !getwinvar(winnr(), '&number')
+ return
+ endif
+ if a:enable
+ set relativenumber
+ else
+ set norelativenumber
+ endif
+endfunction
+autocmd InsertEnter,FocusLost,WinLeave * call s:SetRelativeNumber(0)
+autocmd VimEnter,WinNew,
+ \InsertLeave,FocusGained,WinEnter * call s:SetRelativeNumber(1)
+
+" always show custom listchars
+autocmd VimEnter,WinNew * set list