-
Notifications
You must be signed in to change notification settings - Fork 70
/
dotVimRc
executable file
·337 lines (302 loc) · 11.1 KB
/
dotVimRc
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
" ================================================
" .__ ___.
" ___ __|__| _____ \_ |__ ____ ___ ___
" \ \/ /| | / \ | __ \ / _ \ \ \/ /
" \ / | || Y Y \ | \_\ \( <_> ) > <
" \_/ |__||__|_| / |___ / \____/ /__/\_ \
" \/ \/ \/
" ================================================
"
"
" See `README.md` for features and shortcuts
" Additional features not mentioned in README:
"
" Spell Check:
" Command+shift+p to toggle spell check on comments (underlines in red).
"
" Mac ProTips:
" To further improve the text rendering on Mac OSX:
" 1. From the shell: defaults write org.vim.MacVim MMCellWidthMultiplier 0.9
" 2. Opens all files from other apps in vert split defaults write
" org.vim.MacVim MMVerticalSplit YES
" 3. If when changing monitors, your fonts go from nice and thin to ugly and
" bold: This should fix it:
" Textmate disables font smoothing only for dark backgrounds, but MacVim
" only has a global setting. If you use dark backgrounds consider disabling.
" https://stackoverflow.com/questions/24598390/macvim-thicker-font-rendering-compared-to-textmate
" defaults write org.vim.MacVim AppleFontSmoothing -int 0
" 4. Speed up full screen transition:
" defaults write org.vim.MacVim MMFullScreenFadeTime 0.05
"
" Cygwin:
" Tested and should work. AutoHotkey exist that provide an identical experience
" to the Mac OSX experience.
"
" Bundle System:
" =================================================================
" Uses the VimPlug system. Add bundles to ~/.vim/bundlesVimRc with:
" Plug "githubUser/repo"
" Open a new window and then run `:PlugInstall`
" Close and then reopen the vim window.
" Performance Profiling:
" ========================
" http://stackoverflow.com/questions/12213597/how-to-see-which-plugins-are-making-vim-slow
"
" Find Slow Plugins During Actions:
" =================================
"
" :profile start profile.log
" :profile func *
" :profile file *
" " At this point do slow actions
" :profile pause
" :noautocmd qall!
"
" Profile Startup Time:
" ==================================================================
" mvim --startuptime ~/.vim/timeCost.txt ~/.vim/timeCost.txt
"
" Debugging VimSript Errors:
" ==================================================================
" Ever have this happen to you?
"
" Error <SNR>49_Destroy[10]...Line 3
"
" This is Vim's idea of a good error message (when one of your plugin throws
" an error). See that weird <SNR>49? That's the script number which is
" assigned to the VimScript file behind the scenes (invisibly to you) - Here's
" how you find out which script that is. Execute :scriptnames and find the
" corresponding number in that list. So <SNR>49 means script number 49, and
" Destroy, UnsetIMap are the last two functions in the stack trace (so the
" problem is ultimately in UnsetIMap in my case). And that "line 3"? That's
" not the line number in the file like any reasonable error message would
" display that's the line number within the deepest function.
" Seeing Who Is Setting A Setting:
" =================================================================
" :verbose set settingName?
" Using In Terminal
" ================
" Using VimBox in your terminal is semi-supported. It should work, but it is
" not tested often. If you see something off, please report but a PR is
" the best way to move VimBox forward with terminal support.
"
" Note: If you use iTerm, and you want airline symbols to show up correctly
" you must change the font in *two* places in iTerm. The normal font, and the
" non-ascii font!
"
" Remote Editing:
"
" - Speed up performance at the network layer:
" http://thomer.com/howtos/netrw_ssh.html
" - Help netrw-passwd
"
" - Also good suggestions here: https://stackoverflow.com/questions/28795721/how-to-save-in-vim-a-remote-file-asynchronously
" - As always disable airline/lightline vcs integration.
" - https://github.com/eshion/vim-sync/
" - https://github.com/grantm/bcvi
" - https://github.com/seletskiy/vim-refugi
" if v:version < 799
" echomsg "VimBox works best with Vim8 or newer. Please upgrade your Vim/MacVim"
" endif
if has('gui_win32')
set rtp+=~/.vim
endif
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved
endif
endif
silent! call plug#begin('~/.vim/bundle')
if filereadable(expand("~/.vim/vimrc.custom.before"))
source ~/.vim/vimrc.custom.before
endif
set noswapfile " Don't make backups.
set nowritebackup " Even if you did make a backup, don't keep it around.
set nobackup
syntax on
set virtualedit=block
set tabstop=2
set nonumber
set noswapfile
set mouse=a
set nospell
set ic
set scs
" TODO: Set up mappings to toggle between text mode and code mode.
" Editing code
set nowrap
set wrapmargin=0
" let &textwidth=exists('g:textColumns') && !empty(g:textColumns) ? g:textColumns : 80
set nolinebreak
set hlsearch
set formatoptions+=or
let &tabstop=exists('g:tabSize') ? g:tabSize : 2
let &softtabstop=exists('g:tabSize') ? g:tabSize : 2
let &shiftwidth=exists('g:tabSize') ? g:tabSize : 2
set expandtab
set ignorecase
set infercase
let g:omni_syntax_ignorecase=1
set wildmode=full
set wildignore+=*/node_modules/**
" Including this messes up fugitive in git mergetool:
" set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
set sm! " show matching brace/paren
" Disable visualbell by default
" http://unix.stackexchange.com/a/5313
set visualbell
set t_vb=
" Should avoid "Hit Enter" annoyingness (Does *not* work)
" The final c gets rid of annoying autocomplete messages.
try
set shortmess+=filmnrxoOtTc
catch /E539: Illegal character/
" Some versions do not like c
set shortmess+=filmnrxoOtT
endtry
" Disable Vim's startup screen
set shortmess+=I
" Customize:
" http://vi.stackexchange.com/questions/627/how-can-i-change-vims-start-or-intro-screen
" Mac Support bootstrap
set wildignore+=*.DS_Store
set wildignore+=*/_build**
set wildignore+=*/.ssh
set wildignore+=*/.yarn
set wildignore+=*/.npm
set wildignore+=*/.jenga
" Remove ugly folds
set nofoldenable
" nofoldenable doesn't work in diff mode so do something similar
set diffopt=filler,context:9999
" ============= Configure as Privacy Plugin =========================
" All sensitive data is not stored in your ~/.vimrc folder
" Configure the spelling language and file.
" ================================================================
set spelllang=en
set spellfile=$HOME/vim_spell/en.utf-8.add
" UndoDir:
let s:homeFolder = $HOME
if (exists('g:vimBoxUndoDir'))
let s:undoDir = g:vimBoxUndoDir
else
let s:undoDir = s:homeFolder . '/vimUndo'
endif
set undofile
" " Create undo dir if needed - not in your dotVim folder! It should be local to
" " your computer.
if !isdirectory(s:undoDir)
call mkdir(s:undoDir)
endif
execute "set undodir=".s:undoDir
" Since your file/folder history may show up in a git commit!
let g:netrw_dirhistmax=0
" ================================================================
" =========================== FIX SHELL ==========================
if &shell =~# 'fish$'
set shell=sh
endif
" ================================================================
" http://stackoverflow.com/questions/6852763/vim-quickfix-list-launch-files-in-new-tab
" This is respected by bnext/bprev/bfirst commands!
try
set switchbuf+=useopen,usetab,vsplit
catch /E474: Invalid argument/
set switchbuf+=useopen,usetab
endtry
" A better diff link for macvim
" alias mvimdiff="mvim -O \"+windo set diff scrollbind scrollopt+=hor nowrap\""
" iTerm requires the following commented code to be placed in your .bashrc in
" order for Vim to show full 256 colors.
" export CLICOLOR=1
" export TERM='xterm-256color'
" if [ -e /usr/share/terminfo/x/xterm-256color ]; then
" export TERM='xterm-256color'
" else
" #export TERM='xterm-color'
" export TERM=xterm-256color
" fi
" If your terminal does *not* support 256 color, if if you want better than
" 256, and are willing to limit to base16 colorschemes you enable this:
" (You probably also need the base16 colorscheme shell script to exist
" somewhere in your path) - See the base16 docs.
" let base16colorspace="256"
set t_Co=256
if (empty($TMUX))
" ======================================================================
" This doesn't actually work with vim-airline yet in the most recent
" versions of Vim/NeoVim (except with MacVim strangely). See ~/.vim/neoVimRc
" ======================================================================
if (has("termguicolors"))
" old airline doesn't render correctly without these two obscure settings.
" New airline should work without them.
" https://github.com/vim/vim/issues/993
" set Vim-specific sequences for RGB colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
endif
if (has("nvim"))
source ~/.vim/neoVimRc
endif
if exists('g:nyaovim_version')
source ~/.vim/nyaoVimRc
endif
" Load all the bundles
source ~/.vim/bundlesVimRc
if filereadable(expand("~/.vim/bundlesVimRc.custom"))
source ~/.vim/bundlesVimRc.custom
endif
call plug#end()
" MacVim Quick Start is pretty strange. It's as if it always opens the *next*
" MacVim window whenever you open the currently visible one.
" So this prompt applies to the *next* window you'll open typically - in that
" case.
" Notice the ! not
if !len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
" Everything's already installed. Configure the plugins
source ~/.vim/guiSettingsVimRc
source ~/.vim/keysVimRc
source ~/.vim/customFunctions.vim
" Some vim reset plugin screws up listchars
set listchars = "eol:$"
source ~/.vim/vimrc.custom.after
else
" Don't show statusline when airline might not be loaded or configured.
if exists("g:gui_oni") || has('gui') && has('mac') && has('gui_running')
set background=dark
colorscheme vimBoxColorsDuringLoad
set guioptions-=r
set guioptions-=R
set guioptions-=l
set guioptions-=L
" The backticks and echo make it work better in terminal env
autocmd VimEnter *
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) && 1==confirm("Download and Install Plugins?", "&Yes\n&No", 1)
\| set laststatus=0
\| PlugInstall --sync | echomsg "Open a new window to enjoy the plugins!" | let xx=confirm("Open a New Window For Plugins to Take Effect.")
\| endif
" Source the settings just in case they respond with "No, don't update plugins"
source ~/.vim/guiSettingsVimRc
source ~/.vim/keysVimRc
source ~/.vim/customFunctions.vim
" Some vim reset plugin screws up listchars
set listchars = "eol:$"
" VimBox plugin configuration that has to be performed after loading
" plugins.
source ~/.vim/vimrc.custom.after
else
set laststatus=0
echomsg "Attempting to install plugins. Be patient. Vim is working in the background. It will start eventually."
PlugInstall --sync
source ~/.vim/guiSettingsVimRc
source ~/.vim/keysVimRc
source ~/.vim/customFunctions.vim
" Some vim reset plugin screws up listchars
set listchars = "eol:$"
" VimBox plugin configuration that has to be performed after loading
" plugins.
source ~/.vim/vimrc.custom.after
endif
endif