-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
446 lines (345 loc) · 12.6 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
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"set line number
set number
" Set utf8 as standard enconding and en_US as the standard language
set encoding=utf8
" Case sentitivity for search
set ignorecase
" Turn on incremental search
set incsearch
" keep 50 lines of command line history
set history=50
"
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" do incremental searching
set incsearch
""""""""""""
" vundle
filetype off
" set the runtime path to include Vundle and initialize
call plug#begin()
"required by vundle
Plug 'gmarik/Vundle.vim'
" Ultisnip": snippet engine + snippets
Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
"Solarized": adds solarized colors
Plug 'altercation/vim-colors-solarized'
"Ctrl-p
" Plug 'kien/ctrlp.vim'
"
"Syntastic": syntax checking for many languages
Plug 'scrooloose/syntastic'
"Tagbar": Adds a side buffer listing all the tags in the file (constants,
"macros, functions, classes, methods)
Plug 'majutsushi/tagbar'
"Vim-airline: adds a cool status line at the bottom of the buffer
Plug 'bling/vim-airline'
" Vim-fugitive
" Plug 'tpope/vim-fugitive'
" SuperTab": helps ultisnips work with youcompleteme
Plug 'ervandew/supertab'
" Vim-commentary: provides shortcuts and keybindings for commenting
Plug 'tpope/vim-commentary'
" YouCompleteMe": code completion engine for several languages
Plug 'Valloric/YouCompleteMe'
" YCM-Generator: generates a .ycm_extra_conf.py file needed for c-family
" semantic completion for YCM
Plug 'rdnetto/YCM-Generator'
" vim-go: go development Plug
Plug 'fatih/vim-go'
" vim-javascript: javascript development Plug
Plug 'pangloss/vim-javascript'
"All of your Plugs must be added before the following line
call plug#end()
filetype plugin indent on " required
"""""""
" end Vundle plugin
" Remap keys used for you complete me (ycm) cycling through options
" let g:ycm_key_list_select_completion = [ '<C-k>', '<Enter>', '<Down>']
" let g:ycm_key_list_previous_completion = ['<C-l>', '<Up>']
" make YCM compatible with Ultisnips using supertab
let g:ycm_key_list_select_completion = [ '<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" make ultisnips + YCM work together
" see here: https://stackoverflow.com/questions/14896327/ultisnips-and-youcompleteme
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
"When this option is set to 1, YCM will auto-close the preview window
"after the user accepts the offered completion string. If there is no
"preview window triggered because there is no preview string in completeopt,
"this option is irrelevant. See the g:ycm_add_preview_to_completeopt option
"for more details.
let g:ycm_autoclose_preview_window_after_completion = 0
" Semantic Completer for STL containers and std library objetcs and functions
" (needed to add paths for gcc includes
" using command: "echo | clang -std=c++11 -stdlib=libc++ -v -E -x c++ -"
" the headers path found in in the section "#include <...> search starts here"
" appending them with a "-isystem," before each path, and
" adding them to "flags" variable in ".ycm_extra_conf.py"
" seen here: "https://stackoverflow.com/questions/15266194/my-youcompleteme-vim-plugin-doesnt-support-stl"
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py'
"When this option is set to 1 YCM will ask once per .ycm_extra_conf.py file if
"it is safe to be loaded. This is to prevent execution of malicious code from
"a .ycm_extra_conf.py file you didn't write.
" To avoid asking confirmation for a .ycm_extra_conf.py
let g:ycm_confirm_extra_conf = 0
" From "https://github.com/Valloric/YouCompleteMe#options"
" If you're using YCM's identifier completer in C-family languages but cannot
" use the clang-based semantic completer for those languages and want to use
" the GCC Syntastic checkers, unset this option.
let g:ycm_show_diagnostics_ui = 0
" settings for java autocompletion using eclim
let g:EclimCompletionMethod = 'omnifunc'
" Automatically add imports on save in go files
let g:go_fmt_command = "goimports"
let g:syntastic_go_checkers = ['go']
" let g:syntastic_go_checkers = ['golint', 'govet', 'gometalinter', 'go']
let g:syntastic_go_metalinter_args = ['--disable-all', '--enable=errcheck']
" let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
""""""""""""""""""""""""""
" let airline use powerline fonts (need to install them using package manager)
""""""""""""""""""""""""""
let g:airline_powerline_fonts = 1
" for opening ctrlp in MRU file mode
" let g:ctrlp_cmd = 'CtrlPMRU'
" for letting ctrlp show hidden files
" let g:ctrlp_show_hidden = 1
" recommendation for solarized
" set t_Co=16
" set t_Co=16
let g:solarized_termcolors=16
colorscheme solarized
"colorscheme gotham256
"
"" THIS CODE WAS ADDED BY SOLARIZED_GNOME_TERMINAL script ""
"" FOR CORRECT BEHAVIOUR DO NOT MODIFY ""
" getting time and setting dark or light theme
let sunrise="07:45"
let sunset="18:43"
let hour=strftime("%H:%M")
if sunrise <= hour && hour < sunset
set background=dark
else
set background=dark
endif
"set paste key
set pastetoggle=<F2>
"""""""""""""""""""""""""""""""""""
" mapping h, j, k, l to j, k, l. ;
"""""""""""""""""""""""""""""""""""
" left
nnoremap j h
" down
nnoremap k j
" up
nnoremap l k
" right
nnoremap ; l
" visual mode
" left
xnoremap j h
" down
xnoremap k j
" up
xnoremap l k
" right
xnoremap ; l
"""""""""""""""""""""""""""""""""""
" mapping windows switching to use new map of home keys
"""""""""""""""""""""""""""""""""""
" left
noremap <c-w>j <c-w>h
" down
noremap <c-w>k <c-w>j
" up
noremap <c-w>l <c-w>k
" right
noremap <c-w>; <c-w>l
" map of save(write) to C-s
nmap <c-s> :w<cr>
imap <c-s> <Esc>:w<CR>
" map of quit to C-q
nmap <c-q> :q<cr>
imap <c-q> <Esc>:q<cr>
" mapping of Esc
imap jk <Esc>
cmap jk <c-u><bs>
vmap jk <Esc>
" mapping of Tagbar
nmap <c-m> :Tagbar<CR>
" mapping of h to nothing
nmap h <nop>
" mapping of vertical and horizontal split (just like ctrlp)
nmap <c-x> :sp<CR>
nmap <c-v> :vsp<CR>
" mapping of next tab page
" nmap <C-m> gt
" remap <Leader>
let mapleader="'"
" mapping closing buffer
nmap <Leader>c :bd<CR>
" latex syntastic
let g:syntastic_tex_checkers=['lacheck']
" add qt includes to cpp compiler checks
let g:syntastic_cpp_include_dirs = ['/opt/Qt/5.4/gcc_64/include']
"""""""""""""""""""""""""""""""""""""""""""""""
" Spell checker
"""""""""""""""""""""""""""""""""""""""""""""""
" Pressing 'en/es/de will toggle and untoggle spell checking
map <leader>en :setlocal spell!<cr>
map <leader>es :setlocal spell! spelllang=es<cr>
map <leader>de :setlocal spell! spelllang=de<cr>
" Shortcuts using <leader>
map <leader>n ]s
map <leader>p [s
map <leader>a zg
map <leader>q z=
" folding to automatic and also be able to create new folds
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
"vim-airline
set laststatus=2
" syntastic remommended settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
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 = 0
" highlight current line number gutter
hi clear CursorLine
augroup CLClear
autocmd! colorscheme * hi clear CursorLine
augroup END
hi CursorLineNR cterm=bold
augroup CLNRSet
autocmd! colorscheme * hi CursorLineNR cterm=bold
augroup END
set cursorline
" " set relativenumber
"set tab space = 4
set tabstop=4
set shiftwidth=4
set expandtab
set sts=4
" ctrlp plugin
" set runtimepath^=~/.vim/bundle/ctrlp.vim
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal spell textwidth=78 fo+=t
" For all text files set 'textwidth' to 78 characters.
" source .vimrc any time a file is saved so the background color changes if
" it becomes day/night
" autocmd bufwritepost * source ~/.vimrc
"Vim arduino syntax highlighting
"filetype has to coincide with in *.snippet in snippet folder
au BufRead,BufNewFile *.pde, *.ino set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
" for Markdown
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.md set spell textwidth=78 fo+=t
au BufRead,BufNewFile *.md set commentstring=\<!--%s--\>
"Xetex
autocmd BufRead,BufNewFile *.xtx set filetype=tex
"java
autocmd bufnewfile *.java so ~/Templates/java_template.txt
autocmd bufnewfile *.java exe "1," . 7 . "g/file:.*/s//file: " .expand("%")
autocmd bufnewfile *.java exe "1," . 9 . "g/public class .*/s//public class " .expand("%:t:r") "{"
autocmd bufnewfile *.java exe "1," . 7 . "g/date:.*/s//date: " .strftime("%Y-%m-%d")
autocmd Bufwritepre,filewritepre *.java execute "normal ma"
autocmd bufwritepost,filewritepost *.java execute "normal `a"
" for vhdl
autocmd bufnewfile *.vhd so ~/Templates/VHDL_template.txt
autocmd bufnewfile *.vhd exe "1," . 7 . "g/file:.*/s//file: " .expand("%")
autocmd bufnewfile *.vhd exe "1," . 7 . "g/date:.*/s//date: " .strftime("%Y-%m-%d")
autocmd Bufwritepre,filewritepre *.vhd execute "normal ma"
autocmd bufwritepost,filewritepost *.vhd execute "normal `a"
" for makefile
autocmd bufnewfile Makefile so ~/Templates/Makefile_template.txt
" for CMakeList
autocmd bufnewfile CMakeLists.txt so ~/Templates/CMakeLists_template.txt
autocmd BufRead,BufNewFile *.cpp,*.c,*.h, set textwidth=80 fo+=t
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" For coursera algoriths course
let g:syntastic_java_javac_classpath=".:~/algs4/algs4.jar:~/algs4/stdlib.jar"
" Set syntastic dialect to intel
let g:syntastic_asm_dialect = "intel"