-
Notifications
You must be signed in to change notification settings - Fork 7
/
.vimrc
291 lines (250 loc) · 7.44 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
set nocompatible " be iMproved, required
if filereadable(expand("~/.vim/plugins.vim"))
source ~/.vim/plugins.vim
endif
" => vimrc configuration {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" If there are any machine-specific tweaks for Vim, load them from the following file.
if filereadable(expand("~/.vimrc_local"))
source ~/.vimrc_local
endif
" Watch this file
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" }}}
"set term=screen-256color
" => General {{{
set nowrap
set hidden
set nocp
syntax on
filetype plugin indent on
colorscheme monokai
set wildmenu
set showcmd
syn on se title
set tabstop=4
set softtabstop=8
set shiftwidth=8
set noexpandtab
set hlsearch
set smarttab
set ignorecase
set smartcase
set backspace=indent,eol,start
set nostartofline
set ruler
set laststatus=2
set showmatch
set matchtime=5
set cmdheight=2
set nu
set clipboard=unnamedplus
set wildignore=*.so,*.swp,*.zip,*.d,*.o,*.dtb
set nobackup
set nowb
set noswapfile
set showmode
set nocscopeverbose
set spelllang=en
" }}}
" command :W sudo saves the file
" (useful for handling the permission-denied error)
command! W w !sudo tee % > /dev/null
"
" Quit with :Q
command! -nargs=0 Quit :qa!
autocmd Filetype gitcommit setlocal spell textwidth=72
"
augroup filetime_nasm
au!
au BufRead,BufNewFile *.s set filetype=nasm
augroup END
" My mappings
nnoremap <silent> <leader>l :LinuxCodingStyle<cr>
" Back and forward in tags
map <M-Left> <C-T>
map <M-Right> <C-]>
nnoremap <F2> :set invpaste paste?<CR>
nnoremap <F3> :CtrlPMRUFiles<CR>
nnoremap <F4> :NERDTreeToggle<CR>
nnoremap <silent> <F6> :ToggleBufExplorer<CR>
nmap <F7> :TagbarToggle<CR>
nnoremap <F8> :call ToggleSyntastic()<CR>
vmap <silent> <F10> <Plug>NERDCommenterToggle
nmap <silent> <F10> <Plug>NERDCommenterToggle
nnoremap <silent> <F11> :YRShow<CR>
set pastetoggle=<F2>
" => Tags management {{{
set tags=./tags;
function! LoadCscope()
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
endif
endfunction
au BufEnter /* call LoadCscope()
function! ToggleSyntastic()
for i in range(1, winnr('$'))
let bnum = winbufnr(i)
if getbufvar(bnum, '&buftype') == 'quickfix'
lclose
return
endif
endfor
SyntasticCheck
endfunction
" }}}
" => Abbreviations {{{
iabbrev @@ Ramon Fried <[email protected]>
iabbrev rby Reviewed-By: Ramon Fried <[email protected]>
iabbrev aby Acked-By: Ramon Fried <[email protected]>
iabbrev tby Tested-By: Ramon Fried <[email protected]>
" }}}
" -------------------------------------
" Local vimrc settings
" -------------------------------------
let g:localvimrc_sandbox = 0
let g:localvimrc_ask = 0
" -------------------------------------
" .h file should be treated as c files.
" -------------------------------------
let g:c_syntax_for_h = 1
" ----------------------------------------
" Nerdcommenter settings
" ----------------------------------------
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
let g:NERDToggleCheckAllLines = 1
let g:NERDSpaceDelims = 1
" -----------------------------------------
" Default size for NerdTree and Taglist
" -----------------------------------------
let g:NERDTreeWinSize=50
let g:NERDTreeHijackNetrw=0
"let g:Tlist_WinWidth=50
" -----------------------------------------
" Snippets mapping
" -----------------------------------------
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsSnippetDirectories=["/home/rfried/myrcs/private_snippets"]
" => YCM Configuration {{{
" Provide a way to insert tab without completion, phew...
inoremap <Leader><Tab> <Tab>
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'pandoc' : 1,
\ 'tree' : 1,
\ 'mail' : 1
\}
" -------------------------------------------
" Make YCM and Ultisnips work together nicely
" -------------------------------------------
"let g:ycm_key_list_select_completion=[]
"let g:ycm_key_list_previous_completion=[]
"let g:ycm_key_list_select_completion = ["<C-TAB>", "<Down>"]
"let g:ycm_key_list_previous_completion = ["<C-S-TAB>", "<Up>"]
" }}}
" => Syntactic stuff {{{
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_mode_map = { 'mode': 'passive' }
let g:syntastic_aggregate_errors = 1
let g:syntastic_c_checkers = ['checkpatch']
"let g:syntastic_c_checkpatch_args = "--strict"
"let g:syntastic_cpp_checkers = ['gcc' ]
" }}}
"--------------------------
" Remove trailing whitespace
" --------------------------
function! RemoveTrailingWhitespace()
let b:curcol = col(".")
let b:curline = line(".")
silent! %s/\s\+$//
silent! %s/\(\s*\n\)\+\%$//
call cursor(b:curline, b:curcol)
endfunction
" => NerdTree customization {{{
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
let NERDTreeIgnore=['.*\.o$']
let NERDTreeIgnore+=['.*\.d$']
let NERDTreeIgnore+=['.*\~$']
let NERDTreeIgnore+=['.*\.out$']
let NERDTreeIgnore+=['.*\.so$', '.*\.a$']
" }}}
" => Session plugin {{{
let g:session_autosave='yes'
let g:session_autoload='yes'
let g:session_autosave_periodic = 1
let g:session_autosave_silent = 1
" }}}
" => Airline customization {{{
let g:airline_powerline_fonts = 1
let g:airline#extensions#syntastic#enabled = 1
let airline#extensions#syntastic#error_symbol = 'E:'
let airline#extensions#syntastic#stl_format_err = '%E{[%e(#%fe)]}'
let airline#extensions#syntastic#warning_symbol = 'W:'
let airline#extensions#syntastic#stl_format_warn = '%W{[%w(#%fw)]}'
" }}}
" => Ctrl-p customization {{{
let g:ctrlp_map = '<c-;>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_max_files = 100000
" }}}
"-----------------------
" ack.vim customization
" ----------------------
" Use AG if available
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Don't jump to first result automatically
cnoreabbrev Ack Ack!
noremap <Leader>a :Ack!<cr>
let g:ack_use_dispatch = 1
"-----------------------
" auto-format customization
" ----------------------
" Enable debugging
" let g:autoformat_verbosemode=1
" noremap <F3> :let g:formatters_c = ['my_c_kernelspace'] | Autoformat<CR>
" Disallow vim's automatic formatting incase astyle is missing
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
" Specific formatting options
let g:formatdef_my_c_userspace = '"astyle --mode=cs --style=ansi -pcHs4"'
let g:formatdef_my_c_kernelspace = '"astyle --mode=c --style=knf --indent=tab --align-pointer=name"'
" let g:formatters_c = ['my_c_kernelspace']
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Persistent undo
try
set undodir=~/.vim_runtime/temp_dirs/undodir
set undofile
catch
endtry