dotfiles

My personal home directory config files
git clone https://erai.gay/code/dotfiles/
Log | Files | Refs | LICENSE

sensible.vim (4464B)


      1 " sensible.vim - Defaults everyone can agree on
      2 " Maintainer:   Tim Pope <http://tpo.pe/>
      3 " Version:      2.0
      4 
      5 if exists('g:loaded_sensible') || &compatible
      6   finish
      7 else
      8   let g:loaded_sensible = 'yes'
      9 endif
     10 
     11 " Use :help 'option' to see the documentation for the given option.
     12 
     13 " Disable vi compatibility, if for some reason it's on.
     14 if &compatible
     15   set nocompatible
     16 endif
     17 
     18 " Check if an option was set from a file in $HOME.  This lets us avoid
     19 " overriding options in the user's vimrc, but still override options in the
     20 " system vimrc.
     21 function! s:MaySet(option) abort
     22   if exists('*execute')
     23     let out = execute('verbose setglobal all ' . a:option . '?')
     24   else
     25     redir => out
     26     silent verbose execute 'setglobal all' a:option . '?'
     27     redir END
     28   endif
     29   return out !~# " \\(\\~[\\/]\\|Lua\\)[^\n]*$"
     30 endfunction
     31 
     32 if s:MaySet('backspace')
     33   set backspace=indent,eol,start
     34 endif
     35 " Disable completing keywords in included files (e.g., #include in C).  When
     36 " configured properly, this can result in the slow, recursive scanning of
     37 " hundreds of files of dubious relevance.
     38 set complete-=i
     39 if s:MaySet('smarttab')
     40   set smarttab
     41 endif
     42 
     43 set nrformats-=octal
     44 
     45 " Make the escape key more responsive by decreasing the wait time for an
     46 " escape sequence (e.g., arrow keys).
     47 if !has('nvim') && &ttimeoutlen == -1
     48   set ttimeout
     49   set ttimeoutlen=100
     50 endif
     51 
     52 if has('reltime') && s:MaySet('incsearch')
     53   set incsearch
     54 endif
     55 " Use CTRL-L to clear the highlighting of 'hlsearch' (off by default) and call
     56 " :diffupdate.
     57 if maparg('<C-L>', 'n') ==# ''
     58   nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
     59 endif
     60 
     61 if s:MaySet('laststatus')
     62   set laststatus=2
     63 endif
     64 if s:MaySet('ruler')
     65   set ruler
     66 endif
     67 if s:MaySet('wildmenu')
     68   set wildmenu
     69 endif
     70 
     71 if s:MaySet('scrolloff')
     72   set scrolloff=1
     73 endif
     74 if s:MaySet('sidescroll') && s:MaySet('sidescrolloff')
     75   set sidescroll=1
     76   set sidescrolloff=2
     77 endif
     78 set display+=lastline
     79 if has('patch-7.4.2109')
     80   set display+=truncate
     81 endif
     82 
     83 if s:MaySet('listchars')
     84   set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
     85 endif
     86 
     87 " Delete comment character when joining commented lines.
     88 if v:version > 703 || v:version == 703 && has("patch541")
     89   set formatoptions+=j
     90 endif
     91 
     92 " Replace the check for a tags file in the parent directory of the current
     93 " file with a check in every ancestor directory.
     94 if has('path_extra') && (',' . &g:tags . ',') =~# ',\./tags,'
     95   setglobal tags-=./tags tags-=./tags; tags^=./tags;
     96 endif
     97 
     98 if s:MaySet('autoread')
     99   set autoread
    100 endif
    101 
    102 if s:MaySet('history')
    103   set history=1000
    104 endif
    105 if s:MaySet('tabpagemax')
    106   set tabpagemax=50
    107 endif
    108 
    109 " Persist g:UPPERCASE variables, used by some plugins, in .viminfo.
    110 if !empty(&viminfo)
    111   set viminfo^=!
    112 endif
    113 " Saving options in session and view files causes more problems than it
    114 " solves, so disable it.
    115 set sessionoptions-=options
    116 set viewoptions-=options
    117 
    118 " Allow color schemes to do bright colors without forcing bold.
    119 if &t_Co == 8 && $TERM !~# '^Eterm'
    120   set t_Co=16
    121 endif
    122 
    123 " If the running Vim lacks support for the Fish shell, use Bash instead.
    124 if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276'))
    125   set shell=/usr/bin/env\ bash
    126 endif
    127 
    128 " Disable a legacy behavior that can break plugin maps.
    129 if has('langmap') && exists('+langremap') && &langremap && s:MaySet('langremap')
    130   set nolangremap
    131 endif
    132 
    133 if !(exists('g:did_load_filetypes') && exists('g:did_load_ftplugin') && exists('g:did_indent_on'))
    134   filetype plugin indent on
    135 endif
    136 if has('syntax') && !exists('g:syntax_on')
    137   syntax enable
    138 endif
    139 
    140 if empty(mapcheck('<C-U>', 'i'))
    141   inoremap <C-U> <C-G>u<C-U>
    142 endif
    143 if empty(mapcheck('<C-W>', 'i'))
    144   inoremap <C-W> <C-G>u<C-W>
    145 endif
    146 
    147 " From `:help :DiffOrig`.
    148 if exists(":DiffOrig") != 2
    149   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
    150         \ | diffthis | wincmd p | diffthis
    151 endif
    152 
    153 " Correctly highlight $() and other modern affordances in filetype=sh.
    154 if !exists('g:is_posix') && !exists('g:is_bash') && !exists('g:is_kornshell') && !exists('g:is_dash')
    155   let g:is_posix = 1
    156 endif
    157 
    158 " Load matchit.vim, but only if the user hasn't installed a newer version.
    159 if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
    160   runtime! macros/matchit.vim
    161 endif
    162 
    163 " Enable the :Man command shipped inside Vim's man filetype plugin.
    164 if exists(':Man') != 2 && !exists('g:loaded_man') && &filetype !=? 'man' && !has('nvim')
    165   runtime ftplugin/man.vim
    166 endif