|
7 | 7 | if has('syntax') && !exists('g:syntax_on') |
8 | 8 | syntax enable |
9 | 9 | endif |
| 10 | + |
| 11 | +" No need to duplicate work |
| 12 | +if exists('g:loaded_sensible') |
| 13 | + finish |
| 14 | +endif |
| 15 | + |
| 16 | +" Code taken from https://github.com/tpope/vim-sensible |
| 17 | +" and (mostly comments) from https://github.com/sheerun/vimrc |
| 18 | +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sensible') |
| 19 | + " Autoindent when starting new line, or using `o` or `O`. |
| 20 | + set autoindent |
| 21 | + |
| 22 | + " Allow backspace in insert mode. |
| 23 | + set backspace=indent,eol,start |
| 24 | + |
| 25 | + " Don't scan included files. The .tags file is more performant. |
| 26 | + set complete-=i |
| 27 | + |
| 28 | + " Use 'shiftwidth' when using `<Tab>` in front of a line. |
| 29 | + " By default it's used only for shift commands (`<`, `>`). |
| 30 | + set smarttab |
| 31 | + |
| 32 | + " Disable octal format for number processing. |
| 33 | + set nrformats-=octal |
| 34 | + |
| 35 | + " Allow for mappings including `Esc`, while preserving |
| 36 | + " zero timeout after pressing it manually. |
| 37 | + " (only vim needs a fix for this) |
| 38 | + if !has('nvim') && &ttimeoutlen == -1 |
| 39 | + set ttimeout |
| 40 | + set ttimeoutlen=100 |
| 41 | + endif |
| 42 | + |
| 43 | + " Enable highlighted case-insensitive incremential search. |
| 44 | + set incsearch |
| 45 | + |
| 46 | + " Use <C-L> to clear the highlighting of :set hlsearch. |
| 47 | + if maparg('<C-L>', 'n') ==# '' |
| 48 | + nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L> |
| 49 | + endif |
| 50 | + |
| 51 | + " Always show window statuses, even if there's only one. |
| 52 | + set laststatus=2 |
| 53 | + |
| 54 | + " Show the line and column number of the cursor position. |
| 55 | + set ruler |
| 56 | + |
| 57 | + " Autocomplete commands using nice menu in place of window status. |
| 58 | + " Enable `Ctrl-N` and `Ctrl-P` to scroll through matches. |
| 59 | + set wildmenu |
| 60 | + |
| 61 | + " Keep 5 columns next to the cursor when scrolling horizontally. |
| 62 | + if !&scrolloff |
| 63 | + set scrolloff=1 |
| 64 | + endif |
| 65 | + if !&sidescrolloff |
| 66 | + set sidescrolloff=5 |
| 67 | + endif |
| 68 | + |
| 69 | + " When 'wrap' is on, display last line even if it doesn't fit. |
| 70 | + set display+=lastline |
| 71 | + |
| 72 | + " Force utf-8 encoding |
| 73 | + set encoding=utf-8 |
| 74 | + |
| 75 | + " Set default whitespace characters when using `:set list` |
| 76 | + if &listchars ==# 'eol:$' |
| 77 | + set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ |
| 78 | + endif |
| 79 | + |
| 80 | + " Delete comment character when joining commented lines |
| 81 | + if v:version > 703 || v:version == 703 && has("patch541") |
| 82 | + set formatoptions+=j |
| 83 | + endif |
| 84 | + |
| 85 | + " Search upwards for tags file instead only locally |
| 86 | + if has('path_extra') |
| 87 | + setglobal tags-=./tags tags-=./tags; tags^=./tags; |
| 88 | + endif |
| 89 | + |
| 90 | + " Fix issues with fish shell |
| 91 | + " https://github.com/tpope/vim-sensible/issues/50 |
| 92 | + if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276')) |
| 93 | + set shell=/usr/bin/env\ bash |
| 94 | + endif |
| 95 | + |
| 96 | + " Reload unchanged files automatically. |
| 97 | + set autoread |
| 98 | + |
| 99 | + " Increase history size to 1000 items. |
| 100 | + if &history < 1000 |
| 101 | + set history=1000 |
| 102 | + endif |
| 103 | + |
| 104 | + " Allow for up to 50 opened tabs on Vim start. |
| 105 | + if &tabpagemax < 50 |
| 106 | + set tabpagemax=50 |
| 107 | + endif |
| 108 | + |
| 109 | + " Always save upper case variables to viminfo file. |
| 110 | + if !empty(&viminfo) |
| 111 | + set viminfo^=! |
| 112 | + endif |
| 113 | + |
| 114 | + " Don't save options in sessions and views |
| 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 | + " Load matchit.vim, but only if the user hasn't installed a newer version. |
| 124 | + if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' |
| 125 | + runtime! macros/matchit.vim |
| 126 | + endif |
| 127 | + |
| 128 | + " `Ctrl-U` in insert mode deletes a lot. Use `Ctrl-G` u to first break undo, |
| 129 | + " so that you can undo `Ctrl-U` without undoing what you typed before it. |
| 130 | + if empty(mapcheck('<C-U>', 'i')) |
| 131 | + inoremap <C-U> <C-G>u<C-U> |
| 132 | + endif |
| 133 | + |
| 134 | + if empty(mapcheck('<C-W>', 'i')) |
| 135 | + inoremap <C-W> <C-G>u<C-W> |
| 136 | + endif |
| 137 | +endif |
0 commit comments