-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
252 lines (204 loc) · 6.42 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
"""""""""""""""""""""""""""""""""""""""""""""""""
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
Helptags
""""""""""""""""""""""""""""""""""""""""""""""""
" Generic setup
""""""""""""""""""""""""""""""""""""""""""""""""
filetype plugin indent on
let mapleader = ","
""""""""""""""""""""""""""""""""""""""""""""""""
" Status line stuff - vim-airline
""""""""""""""""""""""""""""""""""""""""""""""""
set laststatus=2 " always show the status line
let g:airline#extensions#tabline#enabled=1
"""""""""""""""""""""""""""""""
" => Syntastic stuff
"""""""""""""""""""""""""""""""
let g:syntastic_check_on_open=1
let g:syntastic_auto_loc_list=0
let g:syntastic_enable_signs=1
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_style_error_symbol = 'Տ'
let g:syntastic_style_warning_symbol = 'Տ'
let g:syntastic_python_checks = ['flake8']
let g:syntastic_python_flake8_args = '--ignore=E501'
let g:syntastic_java_checkers = ['checkstyle']
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Open up the errors
nnoremap <leader>e :Error<cr>
nnoremap <leader>syn :SyntasticCheck<cr>
" Goto the next/previous error
nnoremap <leader>ne :lnext<cr>
nnoremap <leader>pe :lprev<cr>
"""""""""""""""""""""""""""""""
" => Tabular stuff - see http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
"""""""""""""""""""""""""""""""
if exists(":Tabularize")
nnoremap <leader>a= :Tabularize /=<CR>
vnoremap <leader>a= :Tabularize /=<CR>
nnoremap <leader>a: :Tabularize /:\zs<CR>
vnoremap <leader>a: :Tabularize /:\zs<CR>
endif
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
"""""""""""""""""""""""""""""""
" => Ultisnips stuff
"""""""""""""""""""""""""""""""
let g:UltiSnipsEditSplit="context"
let g:UltiSnipsListSnippets="<c-s-tab>"
let g:ultisnips_python_style="sphinx"
"""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""
" Turn on the Wild menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
" Always show current position
set ruler
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Find words as typing out search
set incsearch
" Enable extended % matching
runtime macros/matchit.vim
" Start scrolling before cursor hits top/bottom
set scrolloff=5
" Number of lines to jump when scrolling off screen
" -# = percentage
set scrolljump=-10
" Set the paste toggle
map <F10> :set paste<cr>
map <F11> :set nopaste<cr>
imap <F10> <C-O>:set paste<CR>
imap <F11> <nop>
set pastetoggle=<F11>
""""""""""""""""""""""""""""
" => Tags
""""""""""""""""""""""""""""
" setup tags
set tags=./tags;/
""""""""""""""""""""""""""""
" => Colors and Fonts
""""""""""""""""""""""""""""
" set 256 terminal support
set t_Co=256
" Set the background to dark
set background=dark
" Configure solarized colorscheme
"let g:base16colorspace=256
colorscheme base16-default
" Quick funtion that will
" highlight over 80 columns
autocmd FileType cpp :autocmd! BufWritePre * :match ErrorMsg '\%>80v.\+'
" Use Unix as the standard file type
set ffs=unix,mac,dos
" Set the mouse to always show
set mouse=a
set nomh
""""""""""""""""""""""""""""
" => Syntax highlighting and plugins
""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
"Enable HTML/CCS syntax highlighting in Javascript file
let g:javascript_enable_domhtmlcss = 1
" Enable vim-jsx for plain js files also
let g:jsx_pragma_required = 0
""""""""""""""""""""""""""""
" => Files, backups and undo
""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git etc.
set nobackup
set nowb
set noswapfile
" Auto change directory
set acd
" Echo the full path of file being edited
nnoremap <leader>f :echo expand('%:p')<cr>
" Source and Edit vimrc
nnoremap <leader>src :source ~/.vimrc<cr>
nnoremap <leader>erc :vsp ~/.vimrc<cr>
" Sudo save a file
nnoremap <leader>save :w !sudo dd of=%<cr>
""""""""""""""""""""""""""""
" => Perforce mappings
""""""""""""""""""""""""""""
nnoremap <leader>p4e :!p4 edit %<cr>
nnoremap <leader>p4a :!p4 add %<cr>
nnoremap <leader>p4r :!p4 revert %<cr>
nnoremap <leader>p4l :!p4 login<cr>
nnoremap <leader>p4s :!p4 submit %<cr>
nnoremap <leader>p4d :!p4 diff %<cr>
""""""""""""""""""""""""""""
" => Text, tab and indent related
""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Do not expand tab for Makefiles
autocmd FileType make set noexpandtab
" Be smart when using tabs
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Auto indent and wrap lines
set ai
set wrap
" Set the backspace to work as expected
set backspace=2
" Auto remove trailing whitespace on write
autocmd BufWritePre * :%s/\s\+$//e
"""""""""""""""""""""""""""""""""""
" Window Management Stuff
"""""""""""""""""""""""""""""""""""
" Move to next or previous tab
nnoremap <leader>T :tabn<cr>
nnoremap <leader>P :tabp<cr>
" Increase and Decrease the width of a vertically split window
nnoremap <leader>< :vertical resize -10<cr>
nnoremap <leader>> :vertical resize +10<cr>
" Rotate panes
nnoremap <leader>wvh <C-w>t<C-w>K
nnoremap <leader>whv <C-w>t<C-w>H
"""""""""""""""""""""""""""""""""""
" Operator Maps
"""""""""""""""""""""""""""""""""""
" Operator maps to get inside () '' and "
onoremap in( :<c-u>normal! f(vi(<cr>
onoremap in) :<c-u>normal! F)vi)<cr>
onoremap in{ :<c-u>normal! f{vi{<cr>
onoremap in} :<c-u>normal! F}vi}<cr>
onoremap in[ :<c-u>normal! f[vi[<cr>
onoremap in] :<c-u>normal! F]vi]<cr>
onoremap in' :<c-u>normal! f'vi'<cr>
onoremap il' :<c-u>normal! F'vi'<cr>
onoremap in" :<c-u>normal! f"vi"<cr>
onoremap il" :<c-u>normal! F"vi"<cr>
"""""""""""""""""""""""""""""""""""
" Plugin Maps
"""""""""""""""""""""""""""""""""""
" Toggle TagBar
nnoremap <F8> :TagbarToggle<cr>
" Move to the TagBar if already opened or open and focus
" close the TagBar after selection
nnoremap <leader>tag :TagbarOpen fjc<cr>
" Toggle NERDTree
nnoremap <F6> :NERDTreeToggle<cr>
" List Tasks
nnoremap <leader>l :TaskList<cr>