-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
304 lines (243 loc) · 10.7 KB
/
vimrc
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
"//// GENERAL VIM SETTINGS ////"
set nocompatible " not compatible with vi
filetype off " temporarily disable filetype detection for vundle
set number " show line numbers
set relativenumber " show relative line numbers
set tabstop=4 " tab width
set shiftwidth=4 " shift width
set softtabstop=4 " soft tab stop
set noexpandtab " expand tab
set completeopt-=preview " remove the default preview
set smartindent " smart indent the next line
set foldenable " enable code folding
set encoding=utf-8 " default encoding
set scrolloff=3 " always show 3 lines above and below cursor position
set sidescrolloff=3 " always show 3 characters to the right of horizontal scroll
set nowrap " don't wrap the lines
set textwidth=0 " don't wrap the lines
set wrapmargin=0 " don't wrap the lines
set visualbell " don't beep at me
set ttyfast " better drawing
set backspace=indent,eol,start " additional backspace functionality (as expected)
set laststatus=2 " always show status line
set ignorecase " if all characters are lowercase, it will ignore sensitivity
set smartcase " if some characters are uppercase, it will be case sensitive
set incsearch " incremental search results
set fdo-=search " don't open folds when searching, just show a single hit
set hidden " let me navigate to other buffers without saving
set hlsearch " turn on highlighting for search
set clipboard=unnamed " yank and paste with clipboard support
set cursorline " highlight the current line
set lazyredraw " redraw only when we need to
set formatoptions+=j " better line joins with J
set shell=/bin/zsh " set default shell
set guifont=Hack:h12 " set a better font
"//// PLUGIN CONFIGURATIONS ////"
" setup vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle o_O
Plugin 'VundleVim/Vundle.vim'
" add bundles and their settings
" global variable definitions & keymaps related to the bundle are right below
Plugin 'mhinz/vim-startify'
let g:startify_skiplist = ['tags', 'bundle/.*/doc', 'COMMIT_EDITMSG']
let g:startify_files_number = 8
let g:startify_session_persistence = 1
"Plugin 'chriskempson/base16-vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'hail2u/vim-css3-syntax.git'
Plugin 'StanAngeloff/php.vim'
Plugin '2072/PHP-Indenting-for-VIm'
Plugin 'tpope/vim-markdown'
Plugin 'shawncplus/phpcomplete.vim'
let g:phpcomplete_parse_docblock_comments = 1
Plugin 'kien/ctrlp.vim.git'
" clear the control p cache (detect new files)
nnoremap <leader>p :ClearCtrlPCache<cr>
" always start from the working directory
let g:ctrlp_working_path_mode = 0
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
Plugin 'Lokaltog/vim-easymotion.git'
" setup a very quick and easy way to use easymotion with 'w' and 'b'
map <leader>j <Plug>(easymotion-w)
map <leader>k <Plug>(easymotion-b)
Plugin 'mileszs/ack.vim.git'
Plugin 'scrooloose/nerdcommenter.git'
Plugin 'scrooloose/nerdtree.git'
" use F2 to toggle nerdtree
nnoremap <f2> :NERDTreeToggle<cr>
let NERDTreeShowHidden=1
let NERDTreeIgnore = ['\.DS_Store$', '\.swp$']
Plugin 'tobyS/vmustache'
Plugin 'Raimondi/delimitMate'
let delimitMate_expand_space=1
Plugin 'tpope/vim-fugitive.git'
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gd :Gdiff<CR>
nnoremap <leader>gb :Gblame<CR>
Plugin 'tpope/vim-repeat.git'
Plugin 'tpope/vim-surround.git'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
" Allow JSX in normal JS files
let g:jsx_ext_required = 0
Plugin 'vim-scripts/matchit.zip.git'
Plugin 'bling/vim-airline.git'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#buffer_nr_format = '[%s] '
let g:airline#extensions#whitespace#enabled = 0
" cycle through buffers
nnoremap <leader><tab> :bnext<cr>
nnoremap <leader><s-tab> :bprevious<cr>
Plugin 'scrooloose/syntastic.git'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='❯'
let g:syntastic_aggregate_errors = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'
let g:syntastic_php_checkers = ['php', 'wordpress/phpcs', 'phpmd']
"let g:syntastic_wordpress_phpcs_standard = 'WordPress-VIP'
let g:syntastic_wordpress_phpcs_standard = 'WordPress'
let g:syntastic_wordpress_phpcs_standard_file = 'phpcs.xml.dist'
nnoremap <leader>e :Errors<cr>
Plugin 'terryma/vim-expand-region'
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
Plugin 'skwp/greplace.vim'
set grepprg=ack
let g:grep_cmd_opts = '--noheading'
Plugin 'ntpeters/vim-better-whitespace'
let g:strip_whitespace_on_save = 1
Plugin 'sjl/gundo.vim.git'
nnoremap <leader>u :GundoToggle<CR>
Plugin 'junegunn/vim-easy-align.git'
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" shortcut to format php docblocks (only visually highlight the @ items)
vnoremap <leader>df :EasyAlign 2\ { 'left_margin': 2, 'ignore_groups': ['String'] }<cr>gv:EasyAlign 3\ { 'left_margin': 2, 'ignore_groups': ['String'] }<cr>
vnoremap <leader>af :EasyAlign =<cr>
Plugin 'godlygeek/tabular.git'
Plugin 'terryma/vim-multiple-cursors'
let g:multi_cursor_use_default_mapping = 0
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<C-a>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
" no more plugins
call vundle#end()
"//// FILETYPE SETTINGS ////"
" must be called after all Vundle plugins are defined (not before)
filetype plugin indent on
syntax enable
" Enable omni completion and set spacing preferences per filetype
autocmd FileType css,scss setlocal omnifunc=csscomplete#CompleteCSS smartindent shiftwidth=2 softtabstop=2 tabstop=2 expandtab
"autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS smartindent shiftwidth=4 softtabstop=4 tabstop=4 noexpandtab
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags smartindent shiftwidth=2 softtabstop=2 tabstop=2 noexpandtab
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS smartindent shiftwidth=2 softtabstop=2 tabstop=2 expandtab
"autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS smartindent shiftwidth=4 softtabstop=4 tabstop=4 noexpandtab
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags smartindent shiftwidth=2 softtabstop=2 tabstop=2 expandtab
autocmd FileType php,php.wordpress setlocal omnifunc=phpcomplete#CompletePHP smartindent shiftwidth=4 softtabstop=4 tabstop=4 noexpandtab
autocmd FileType ruby,haml,eruby,yaml,cucumber,ejs,coffee,json setlocal smartindent shiftwidth=2 softtabstop=2 tabstop=2 expandtab
"//// HIGHLIGHT SETTINGS ////"
" put highlight variables down here because of vundle load order
hi StartifyHeader ctermfg=46 guifg=#00ff00
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
hi Search guibg=black guifg=white gui=underline ctermbg=black ctermfg=white cterm=underline
"//// TERMINAL SETTINGS ////"
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
"//// CUSTOM MAPPINGS ////"
" use <leader> for plugin mappings & shortcuts
" GENERAL MAPPINGS
" map spacebar to leader key
map <space> <leader>
" quick escape when in insert mode
imap jj <esc>
" use tab key to navigate between windows in normal mode
nnoremap <Tab> <C-W>w
" remap the vertical scroll to ctrl-j/k and horizontal scroll to ctrl-h/l
nnoremap <C-j> 4<C-e>
nnoremap <C-k> 4<C-y>
nnoremap <C-h> 4zh
nnoremap <C-l> 4zl
" clear the search buffer when hitting return
nnoremap <CR> :nohlsearch<cr>
" map leader w as a quick save
nnoremap <leader>w :w<CR>
" map leader q as a quick quit
"nnoremap <leader>q :q<CR>
nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
" SHORTCUTS
" easier to remember ctag 'go back' using other bracket
nnoremap <C-[> <C-t>
" cycle through buffers
nnoremap <c-tab> :bnext<cr>
nnoremap <s-c-tab> :bprevious<cr>
" source the settings
nnoremap <leader>sv :source $MYVIMRC<CR>
" COMPLEX COMMANDS
" shortcut to (f)old an html (t)ag
nnoremap <leader>ft Vatzf
" shortcut to (f)old (b)races, must be inside braces to fold
nnoremap <leader>fb zfa{
" do a (v)ertical (s)plit and go to window
nnoremap <leader>vs <C-w>v<C-w>l
" do a (h)orizontal (s)plit and go to window
nnoremap <leader>hs <C-w>s<C-w>j
" (r)efresh c(t)ags manually - note, i have a ~/.ctags with my preferences
nnoremap <leader>rt :! ctags -R --fields=+l --exclude=.git --languages=-javascript *<cr>
" clean up extra parens spacing
vnoremap <leader>( :s/( /(/g<cr>
" clean up extra parens spacing
vnoremap <leader>) :s/ )/)/g<cr>
" switch to php filetype mode
nnoremap <leader>1 :set filetype=php<cr>
" switch to php.wordpress filetype mode
nnoremap <leader>2 :set filetype=php.wordpress<cr>
" switch to html filetype mode
nnoremap <leader>3 :set filetype=html<cr>
" paste the buffer and drop the overridden contents into the black hole (preserves the buffer)
vnoremap p "_dP
"//// HEADER ////"
let g:startify_custom_header = [
\'',
\' |~',
\' |.---.',
\' .`_____`. /\`',
\' |~xxxxx~| ||',
\' |_ # _| ||',
\' .------`-#-`-----.',
\' (___|\_________/|_.`.',
\' / | _________ | | |',
\' / |/ _|_ \| | |',
\' / /X| __|__ |/ `.|',
\' ( --< \\/ _\//|_ |`.',
\' `. ~----.-~=====,:=======',
\' ~-._____/___:__(``/| |',
\' | | XX|~ | |',
\' \__/======| /| `.|',
\' |_\|\ /|/_| )',
\' |_ \__/ _| .-`',
\' | \ .`||`. / |(_|',
\' | ||.``.|| | )',
\' | ``| |`` | /',
\' | | | |\/',
\'',
\' IT''S ABOUT THE BOUNTY',
\'',
\]