forked from PegasusWang/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
general.vim
290 lines (252 loc) · 8.89 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
" Neo/vim Settings
" ===
" General {{{
set mouse=nv " Disable mouse in command-line mode
set modeline " automatically setting options from modelines
set report=2 " 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 and friends
set isfname-== " Remove =, detects filename in var=/foo/bar
set virtualedit=block " Position cursor anywhere in visual block
set synmaxcol=2500 " 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
set formatoptions-=o " Disable comment-continuation (normal 'o'/'O')
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 and sessions:
set viewoptions=folds,cursor,curdir,slash,unix
set sessionoptions=curdir,help,tabpages,winsize
if has('mac') && has('vim_starting')
let g:clipboard = {
\ 'name': 'macOS-clipboard',
\ 'copy': {
\ '+': 'pbcopy',
\ '*': 'pbcopy',
\ },
\ 'paste': {
\ '+': 'pbpaste',
\ '*': 'pbpaste',
\ },
\ 'cache_enabled': 0,
\ }
endif
if has('clipboard') && has('vim_starting')
" set clipboard& clipboard+=unnamedplus
set clipboard& clipboard^=unnamed,unnamedplus
endif
" }}}
" Wildmenu {{{
" --------
if has('wildmenu')
if ! has('nvim')
set nowildmenu
set wildmode=list:longest,full
endif
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+=__pycache__,*.egg-info,.pytest_cache,.mypy_cache/**
endif
" }}}
" Vim Directories {{{
" ---------------
set undofile swapfile nobackup
set directory=$DATA_PATH/swap//,$DATA_PATH,~/tmp,/var/tmp,/tmp
set undodir=$DATA_PATH/undo//,$DATA_PATH,~/tmp,/var/tmp,/tmp
set backupdir=$DATA_PATH/backup/,$DATA_PATH,~/tmp,/var/tmp,/tmp
set viewdir=$DATA_PATH/view/
set spellfile=$VIM_PATH/spell/en.utf-8.add
" History saving
set history=2000
if has('nvim') && ! has('win32') && ! has('win64')
set shada=!,'100,<20,@100,s10,h,r/tmp,r/private/var
else
set viminfo='100,<20,@50,h,n$DATA_PATH/viminfo
endif
augroup user_persistent_undo
autocmd!
au BufWritePre /tmp/* setlocal noundofile
au BufWritePre COMMIT_EDITMSG setlocal noundofile
au BufWritePre MERGE_MSG setlocal noundofile
au BufWritePre *.tmp setlocal noundofile
au BufWritePre *.bak setlocal noundofile
augroup END
" If sudo, disable vim swap/backup/undo/shada/viminfo writing
if $SUDO_USER !=# '' && $USER !=# $SUDO_USER
\ && $HOME !=# expand('~'.$USER, 1)
\ && $HOME ==# expand('~'.$SUDO_USER, 1)
set noswapfile
set nobackup
set nowritebackup
set noundofile
if has('nvim')
set shada="NONE"
else
set viminfo="NONE"
endif
endif
" Secure sensitive information, disable backup files in temp directories
if exists('&backupskip')
set backupskip+=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*,/private/var/*
set backupskip+=.vault.vim
endif
" Disable swap/undo/viminfo files in temp directories or shm
augroup user_secure
autocmd!
silent! autocmd BufNewFile,BufReadPre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*,/private/var/*,.vault.vim
\ setlocal noswapfile noundofile
\ | set nobackup nowritebackup
\ | if has('nvim') | set shada= | else | set viminfo= | endif
augroup END
" }}}
" Tabs and Indents {{{
" ----------------
set textwidth=120 " Text width maximum chars before wrapping
set noexpandtab " Don't expand tabs to spaces
set tabstop=4 " The number of spaces a tab is
set shiftwidth=4 " Number of spaces to use in auto(indent)
set softtabstop=-1 " Automatically keeps in sync with shiftwidth
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'
if exists('&breakindent')
set breakindentopt=shift:2,min:20
endif
" }}}
" Timing {{{
" ------
set timeout ttimeout
set timeoutlen=500 " Time out on mappings
set ttimeoutlen=10 " Time out on key codes
set updatetime=400 " Idle time to write swap and trigger CursorHold
set redrawtime=2000 " Time in milliseconds for stopping display redraw
" }}}
" 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 wrapscan " Searches wrap around the end of the file
set complete=.,w,b,k " C-n completion: Scan buffers, windows and dictionary
if exists('+inccommand')
set inccommand=nosplit
endif
if executable('rg')
set grepformat=%f:%l:%c:%m
let &grepprg =
\ 'rg --vimgrep --no-heading' . (&smartcase ? ' --smart-case' : '') . ' --'
elseif executable('ag')
set grepformat=%f:%l:%c:%m
let &grepprg =
\ 'ag --vimgrep' . (&smartcase ? ' --smart-case' : '') . ' --'
endif
" }}}
" 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 " Look for matching window buffers first
set backspace=indent,eol,start " Intuitive backspacing in insert mode
set diffopt=filler,iwhite " Diff mode: show fillers, ignore whitespace
set completeopt=menuone " Always show menu, even for one item
if has('patch-7.4.775')
" Do not select a match in the menu.
" Do not insert any text for a match until the user selects from menu.
set completeopt+=noselect,noinsert
endif
if has('patch-8.1.0360') || has('nvim-0.5')
set diffopt=internal,algorithm:patience
" set diffopt=indent-heuristic,algorithm:patience
endif
" Use the new Neovim :h jumplist-stack
if has('nvim-0.5')
set jumpoptions=stack
endif
" }}}
" Editor UI {{{
" --------------------
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 " Don't 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 winminwidth=10 " Minimum width for inactive windows
" set winheight=4 " Minimum height for active window
" set winminheight=4 " Minimum height for inactive window
set pumheight=15 " Pop-up menu's line height
set helpheight=12 " Minimum help window height
set previewheight=12 " Completion preview height
set showcmd " 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=+0 " Column highlight at textwidth's max character-limit
set display=lastline
if has('folding') && has('vim_starting')
set foldenable
set foldmethod=indent
set foldlevelstart=99
endif
if has('nvim-0.4')
set signcolumn=auto:1
elseif exists('&signcolumn')
set signcolumn=auto
endif
" UI Symbols
" icons: ▏│ ¦ ╎ ┆ ⋮ ⦙ ┊
let &showbreak='↳ '
set listchars=tab:\▏\ ,extends:⟫,precedes:⟪,nbsp:␣,trail:·
" set fillchars=foldopen:O,foldclose:x
" set fillchars=vert:▉,fold:─
if has('patch-7.4.314')
" Do not display completion messages
set shortmess+=c
endif
if has('patch-7.4.1570')
" Do not display message when editing files
set shortmess+=F
endif
" if exists('+previewpopup')
" set previewpopup=height:10,width:60
" endif
" Pseudo-transparency for completion menu and floating windows
if has('termguicolors') && &termguicolors
if exists('&pumblend')
set pumblend=10
endif
if exists('&winblend')
set winblend=10
endif
endif
" solve wrong encoding
if has("multi_byte")
set encoding=utf-8
set termencoding=utf-8
set formatoptions+=mM
set fencs=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
endif
" }}}
" vim: set foldmethod=marker ts=2 sw=2 tw=80 noet :