forked from rafi/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.vim
237 lines (209 loc) · 8.01 KB
/
general.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
" General Settings
"---------------------------------------------------------
" General {{{
set mouse=nv " Disable mouse in command-line mode
set modeline " automatically setting options from modelines
set report=0 " Don't report on line changes
set errorbells " Trigger bell on error
set visualbell " Use visual bell instead of beeping
set hidden " hide buffers when abandoned instead of unload
set fileformats=unix,dos,mac " Use Unix as the standard file type
set magic " For regular expressions turn magic on
set path=.,** " Directories to search when using gf
set virtualedit=block " Position cursor anywhere in visual block
set synmaxcol=1000 " Don't syntax highlight long lines
set formatoptions+=1 " Don't break lines after a one-letter word
set formatoptions-=t " Don't auto-wrap text
if has('patch-7.3.541')
set formatoptions+=j " Remove comment leader when joining lines
endif
if has('vim_starting')
set encoding=utf-8
scriptencoding utf-8
endif
" What to save for views:
set viewoptions-=options
set viewoptions+=slash,unix
" What to save in sessions:
set sessionoptions-=blank
set sessionoptions-=options
set sessionoptions-=globals
set sessionoptions-=folds
set sessionoptions-=help
set sessionoptions-=buffers
set sessionoptions+=tabpages
if has('clipboard')
set clipboard& clipboard+=unnamedplus
endif
" }}}
" Wildmenu {{{
" --------
if has('wildmenu')
set nowildmenu
set wildmode=list:longest,full
set wildoptions=tagfile
set wildignorecase
set wildignore+=.git,.hg,.svn,.stversions,*.pyc,*.spl,*.o,*.out,*~,%*
set wildignore+=*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store
set wildignore+=**/node_modules/**,**/bower_modules/**,*/.sass-cache/*
set wildignore+=application/vendor/**,**/vendor/ckeditor/**,media/vendor/**
set wildignore+=__pycache__,*.egg-info
endif
" }}}
" Vim Directories {{{
" ---------------
set undofile swapfile nobackup
set directory=$VARPATH/swap//,$VARPATH,~/tmp,/var/tmp,/tmp
set undodir=$VARPATH/undo//,$VARPATH,~/tmp,/var/tmp,/tmp
set backupdir=$VARPATH/backup/,$VARPATH,~/tmp,/var/tmp,/tmp
set viewdir=$VARPATH/view/
set nospell spellfile=$VIMPATH/spell/en.utf-8.add
" History saving
set history=2000
if has('nvim')
" ShaDa/viminfo:
" ' - Maximum number of previously edited files marks
" < - Maximum number of lines saved for each register
" @ - Maximum number of items in the input-line history to be
" s - Maximum size of an item contents in KiB
" h - Disable the effect of 'hlsearch' when loading the shada
set shada='300,<50,@100,s10,h
else
set viminfo='300,<10,@50,h,n$VARPATH/viminfo
endif
" }}}
" Tabs and Indents {{{
" ----------------
set textwidth=80 " Text width maximum chars before wrapping
set noexpandtab " Don't expand tabs to spaces.
set tabstop=2 " The number of spaces a tab is
set softtabstop=2 " While performing editing operations
set shiftwidth=2 " Number of spaces to use in auto(indent)
set smarttab " Tab insert blanks according to 'shiftwidth'
set autoindent " Use same indenting on new lines
set smartindent " Smart autoindenting on new lines
set shiftround " Round indent to multiple of 'shiftwidth'
" }}}
" Timing {{{
" ------
set timeout ttimeout
set timeoutlen=750 " Time out on mappings
set updatetime=1000 " Idle time to write swap and trigger CursorHold
" Time out on key codes
set ttimeoutlen=10
" }}}
" Searching {{{
" ---------
set ignorecase " Search ignoring case
set smartcase " Keep case when searching with *
set infercase " Adjust case in insert completion mode
set incsearch " Incremental search
set hlsearch " Highlight search results
set wrapscan " Searches wrap around the end of the file
set showmatch " Jump to matching bracket
set matchpairs+=<:> " Add HTML brackets to pair matching
set matchtime=1 " Tenths of a second to show the matching paren
set cpoptions-=m " showmatch will wait 0.5s or until a char is typed
" }}}
" Behavior {{{
" --------
set nowrap " No wrap by default
set linebreak " Break long lines at 'breakat'
set breakat=\ \ ;:,!? " Long lines break chars
set nostartofline " Cursor in same column for few commands
set whichwrap+=h,l,<,>,[,],~ " Move to following line on certain keys
set splitbelow splitright " Splits open bottom right
set switchbuf=useopen,usetab " Jump to the first open window in any tab
set switchbuf+=vsplit " Switch buffer behavior to vsplit
set backspace=indent,eol,start " Intuitive backspacing in insert mode
set diffopt=filler,iwhite " Diff mode: show fillers, ignore white
set showfulltag " Show tag and tidy search in completion
set complete=. " No wins, buffs, tags, include scanning
set completeopt=menuone " Show menu even for one item
set completeopt+=noselect " Do not select a match in the menu
if has('patch-7.4.775')
set completeopt+=noinsert
endif
if exists('+inccommand')
set inccommand=nosplit
endif
" }}}
" Editor UI Appearance {{{
" --------------------
set noshowmode " Don't show mode in cmd window
set shortmess=aoOTI " Shorten messages and don't show intro
set scrolloff=2 " Keep at least 2 lines above/below
set sidescrolloff=5 " Keep at least 5 lines left/right
set number " Show line numbers
set noruler " Disable default status ruler
set list " Show hidden characters
set showtabline=2 " Always show the tabs line
set winwidth=30 " Minimum width for active window
set winheight=1 " Minimum height for active window
set pumheight=15 " Pop-up menu's line height
set helpheight=12 " Minimum help window height
set previewheight=12 " Completion preview height
set noshowcmd " Don't show command in status line
set cmdheight=2 " Height of the command line
set cmdwinheight=5 " Command-line lines
set noequalalways " Don't resize windows on split or close
set laststatus=2 " Always show a status line
set colorcolumn=100 " Highlight the 100th character limit
set display=lastline
" Do not display completion messages
" Patch: https://groups.google.com/forum/#!topic/vim_dev/WeBBjkXE8H8
if has('patch-7.4.314')
set shortmess+=c
endif
" Do not display message when editing files
if has('patch-7.4.1570')
set shortmess+=F
endif
" For snippet_complete marker
if has('conceal') && v:version >= 703
set conceallevel=2 concealcursor=niv
endif
" }}}
" Folds {{{
" -----
" FastFold
" Credits: https://github.com/Shougo/shougo-s-github
autocmd MyAutoCmd TextChangedI,TextChanged *
\ if &l:foldenable && &l:foldmethod !=# 'manual' |
\ let b:foldmethod_save = &l:foldmethod |
\ let &l:foldmethod = 'manual' |
\ endif
autocmd MyAutoCmd BufWritePost *
\ if &l:foldmethod ==# 'manual' && exists('b:foldmethod_save') |
\ let &l:foldmethod = b:foldmethod_save |
\ execute 'normal! zx' |
\ endif
if has('folding')
set foldenable
set foldmethod=syntax
set foldlevelstart=99
set foldtext=FoldText()
endif
" Improved Vim fold-text
" See: http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
function! FoldText()
" Get first non-blank line
let fs = v:foldstart
while getline(fs) =~? '^\s*$' | let fs = nextnonblank(fs + 1)
endwhile
if fs > v:foldend
let line = getline(v:foldstart)
else
let line = substitute(getline(fs), '\t', repeat(' ', &tabstop), 'g')
endif
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let foldSize = 1 + v:foldend - v:foldstart
let foldSizeStr = ' ' . foldSize . ' lines '
let foldLevelStr = repeat('+--', v:foldlevel)
let lineCount = line('$')
let foldPercentage = printf('[%.1f', (foldSize*1.0)/lineCount*100) . '%] '
let expansionString = repeat('.', w - strwidth(foldSizeStr.line.foldLevelStr.foldPercentage))
return line . expansionString . foldSizeStr . foldPercentage . foldLevelStr
endfunction
" }}}
" vim: set foldmethod=marker ts=2 sw=2 tw=80 noet :