-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
311 lines (234 loc) · 7.88 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
305
306
307
308
309
310
311
" tuck backup/undo files somewhere that doesn't pollute working directories
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set undodir=~/.vim/tmp
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key Mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap arrow keys because they broke when upgrading to vim 7.3
" Most people could remove this
map! [D <Left>
map! [C <Right>
map! [A <Up>
map! [B <Down>
inoremap [D <Left>
inoremap [C <Right>
inoremap [A <Up>
inoremap [B <Down>
" make CTRL-J and CTRL-K navigate between buffers
map <C-k> :bn<CR>
map <C-j> :bp<CR>
" make capitalized versions of :w and :q operate as you'd expect
command! -bang Q quit<bang>
command! -bang W write<bang>
" map undo tree to F5 (navigate through under states)
nnoremap <F5> :GundoToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Pathogen
"
call pathogen#infect()
filetype off " Pathogen needs to run before plugin indent on
call pathogen#incubate()
call pathogen#helptags() " generate helptags for everything in 'runtimepath'
filetype plugin indent on " this needs to happen after Pathogen
"
" Airline
"
" use the powerline fonts
let g:airline_powerline_fonts = 1
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" show buffers
let g:airline#extensions#tabline#show_buffers = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#tab_min_count = 0
" only show filename in buffer tab
let g:airline#extensions#tabline#fnamemod = ':t'
" define buffer tab separator characters
"let g:airline#extensions#tabline#left_sep = '⮀'
"let g:airline#extensions#tabline#left_alt_sep = '⮁'
"let g:airline#extensions#tabline#right_sep = '⮂'
"let g:airline#extensions#tabline#right_alt_sep = '⮃'
" Set airline symbols
"let g:airline_symbols = {}
"let g:airline_left_sep = '⮀'
"let g:airline_left_alt_sep = '⮁'
"let g:airline_right_sep = '⮂'
"let g:airline_right_alt_sep = '⮃'
"let g:airline_symbols.branch = '⭠'
"let g:airline_symbols.readonly = '⭤'
"let g:airline_symbols.linenr = '⭡'
"
" Tagbar
"
" set F8 to toggle tagbar
nmap <F8> :TagbarToggle<CR>
let g:tagbar_phpctags_bin='/usr/local/bin'
set tags=~/.vim/tags/laravel
"
" Detect Indent
"
"autocmd BufReadPost * :DetectIndent
"let g:detectindent_preferred_expandtab = 1
"let g:detectindent_preferred_indent = 2
"
" Zen Coding
"
let g:user_zen_expandabbr_key = '<c-e>'
let g:use_zen_complete_tag = 1
"
" PHP Documentor for VIM (PDV)
"
let pdv_template_dir = $HOME ."/dotfiles/vim/templates"
nnoremap <buffer> <C-p> :call pdv#DocumentCurrentLine()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax Files
"
" IMPORTANT: this section should come after Pathogen because
" there are file types that rely on multiple syntax
" plugins that will get overriden otherwise.
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile *.htm,*.html set filetype=html
au! Syntax html source ~/.vim/syntax/html.vim
au BufRead,BufNewFile *.php set filetype=php
au! Syntax php source ~/.vim/syntax/php.vim
au BufRead,BufNewFile *.twig set filetype=html.twig
"au! Syntax twig source ~/.vim/syntax/twig.vim
au BufRead,BufNewFile *.sass,*.sass set filetype=sass
au! Syntax sass source ~/.vim/syntax/sass.vim
au BufRead,BufNewFile *.scss,*.scss set filetype=scss
au! Syntax scss source ~/.vim/syntax/scss.vim
au BufRead,BufNewFile *.haml,*.haml set filetype=haml
au! Syntax haml source ~/.vim/syntax/haml.vim
au BufRead,BufNewFile *.jade,*.jade set filetype=jade
au! Syntax jade source ~/.vim/syntax/jade.vim
au BufRead,BufNewFile *.blade.php,*.blade.php set filetype=blade
au! Syntax blade source ~/.vim/bundles/vim-blade/syntax/blade.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" spaces instead of tabs. Prefer 4 spaces
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
" cursor style in insert mode
" comment this out if the cursor looks all funky
" let &t_SI .= "\e[3 q"
" let &t_EI .= "\e[1 q"
" left-edge line numbering
set nu
hi LineNr ctermfg=black ctermbg=none
" possibly helpful with the whole up arrow mapping issue
set nocompatible
" Sets subtle column marker at 80 chars
set colorcolumn=80
highlight ColorColumn ctermbg=8 cterm=bold
set so=7 " Set 7 lines to the curors - when moving vertical..
"Turn on WiLd menu -- autocompletion for vim commands (ex: ':color <Tab>')
set wildmenu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hid "Change buffer - without saving
set backspace=indent,eol,start " make backspace work as expected
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search terms
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" List characters
set listchars=trail:.,tab:██,eol:·
highlight SpecialKey guifg=red ctermfg=black cterm=none
" highlight current line
set cursorline
hi CursorLine cterm=bold ctermbg=black ctermfg=none guibg=darkred guifg=white
" tab (not tab characters, but tab screen) colors
hi TabLine ctermfg=white ctermbg=green cterm=none
hi TabLineSel ctermfg=white ctermbg=none cterm=none
hi TabLineFill ctermfg=red ctermbg=green cterm=none
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
let g:solarized_termcolors=256
" set solarized color scheme based on time of day (light = day, dark = night)
let hour = strftime("%H")
if 6 <= hour && hour < 18
set background=light
else
set background=dark
endif
colorscheme solarized
" set the encoding and language
set encoding=utf8
try
lang en_US
catch
endtry
""""""""""""""""""""""""""""""
" Visual mode related
""""""""""""""""""""""""""""""
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
""""""""""""""""""""""""""""""
" Other helpful stuff
""""""""""""""""""""""""""""""
" remove trailing whitespace when buffer is saves
autocmd BufWritePre * :%s/\s\+$//e
" allows ALT keys to be mapped
" see: http://stackoverflow.com/a/10216459
let c='a'
while c <= 'z'
exec "set <A-".c.">=\e".c
exec "imap \e".c." <A-".c.">"
let c = nr2char(1+char2nr(c))
endw
set timeout ttimeoutlen=50
" Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
" Powerline setup
set laststatus=2
set term=xterm-256color
set termencoding=utf-8
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ Regular:12
" set guifont=Ubuntu\ Mono
let g:Powerline_symbols = 'fancy'