-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
395 lines (313 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
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
set encoding=utf-8
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" All of your Plugins must be added before the following line
Bundle 'idanarye/vim-dutyl'
Bundle 'dlang-community/DCD'
"Bundle 'landaire/deoplete-d'
"Bundle 'tweekmonster/deoplete-clang2'
"Bundle 'Shougo/deoplete.nvim'
Bundle 'Valloric/YouCompleteMe'
Bundle 'rking/ag.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/syntastic'
Bundle 'kien/ctrlp.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'bkad/CamelCaseMotion'
Plugin 'mhinz/vim-startify'
" ultisnips
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Bundle 'ervandew/supertab'
Plugin 'kiith-sa/DSnips'
" JS plugins
Bundle 'jelera/vim-javascript-syntax'
Bundle 'pangloss/vim-javascript'
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'Raimondi/delimitMate'
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
syntax enable
set autoindent
set number
set so=7
set ruler
set cmdheight=2
set ignorecase
"set smartcase
set hlsearch
set incsearch
set magic
set smarttab
" Set tabs and their width for kernel development
if (system('pwd | grep "/home/fawkes/Facultate/AnulIV/SO2\|/home/fawkes/SO2"') != "")
"echom "Working on kernel stuff"
set noexpandtab
set shiftwidth=8
set tabstop=8
else
"echom "Not working on kernel stuff"
set expandtab
set shiftwidth=4
set tabstop=4
endif
set ai
set si
set wrap
" no swap file
set noswapfile
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when need to
set showmatch " highlight matching braces
set formatoptions-=o "dont continue comments when pushing o/O
"set foldenable " enable folding
"set foldmethod=indent " fold based on indent level
set pastetoggle=<F2>
filetype indent on " load filetype-specific indent files
set exrc " enable per directory vimrc
set secure " ensures that shell, autocmd and write commands are not allowed
" in the .vimrc file that was found in the current directory
"""""""""""""""
" DelimitMate "
"""""""""""""""
imap <C-c> <CR><Esc>O
"""""""""""""""
" Status line "
"""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ Column:\ %c
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
""""""""""""
" NERDTree "
""""""""""""
" Map C-N to open NERDTree
map <C-N> :NERDTreeToggle<CR>
" Close vim when the only window left open is NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"""""""""
" CtrlP "
"""""""""
let g:ctrlp_working_path_mode = 'ra'
" Move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
map <leader>1 1gt
map <leader>2 2gt
map <leader>3 3gt
map <leader>4 4gt
map <leader>5 5gt
map <leader>6 6gt
map <leader>7 7gt
map <leader>8 8gt
map <leader>9 1gtgT
" Resize window
nnoremap + <C-W>+
nnoremap _ <C-W>-
nnoremap = <C-W>>
nnoremap - <C-W><
"""""""""""""""""""""""""
" Highlight cursor line "
"""""""""""""""""""""""""
set cursorline
highlight CursorLine term=bold cterm=bold guibg=Grey40 ctermbg=None ctermfg=None
hi NonText ctermbg=None
"""""""""""""""""""
" Set colorscheme "
"""""""""""""""""""
" colorscheme peaksea.vim
if ! has("gui_running")
set t_Co=256
endif
" colors peaksea
colors gruvbox
"colors transparent
"colors badwolf
" feel free to choose :set background=light for a different style
set background=dark
"set background=light
" From Vlad Dogaru
if has("cscope")
" Look for a 'cscope.out' file starting from the current directory,
" going up to the root directory.
let s:dirs = split(getcwd(), "/")
while s:dirs != []
let s:path = "/" . join(s:dirs, "/")
if (filereadable(s:path . "/cscope.out"))
execute "cs add " . s:path . "/cscope.out " . s:path . " -v"
break
endif
let s:dirs = s:dirs[:-2]
endwhile
set csto=0 " Use cscope first, then ctags
set cst " Only search cscope
set csverb " Make cs verbose
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
" Open a quickfix window for the following queries.
set cscopequickfix=s-,c-,d-,i-,t-,e-,g-
endif
" Kudos darius-m
vnoremap <C-k> :<C-u>silent! '<,'>m '<-2<CR>`[V`]
vnoremap <C-j> :<C-u>silent! '<,'>m '>+1<CR>`[V`]
" Mark tabs and spaces
set list listchars=tab:»\ ,trail:·,extends:»,precedes:«
" Open new vertical splits to the right of current one.
set splitright
" End from VD
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
"""""""
" YCM "
"""""""
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_always_populate_location_list = 1
"let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_complete_in_comments = 1
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_semantic_triggers = {'d': ['.', 're![a-zA-Z]']}
" Add autocomplete for languages that are not supported by ycm
"if has("autocmd") && exists("+omnifunc")
"autocmd Filetype *
"\ if &omnifunc == \"\" |
"\ setlocal omnifunc=syntaxcomplete#Complete |
"\ endif
"endif
"""""""""""""
" Syntastic "
"""""""""""""
let g:syntastic_check_on_open = 1
let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_d_config_file="~/.syntastic_d_config"
let g:syntastic_d_compiler = "/home/edis/workspace/dlang/code/dmd/generated/linux/release/64/dmd"
let g:syntastic_d_compiler_options = "-I~/workspace/dlang/code/druntime/import/ -I~/workspace/dlang/code/phobos -L-L$HOME/workspace/dlang/code/phobos/generated/linux/release/64/"
" Go to previous error. Allow :lprev to work with empty location list, or at first location
function! <SID>LocationPrevious()
try
lprev
catch /:E553:/
llast
catch /:E\%(42\|776\):/
echo "Location list empty"
catch /.*/
echo v:exception
endtry
endfunction
" Go to next error. Allow :lnext to work with empty location list, or at first location
function! <SID>LocationNext()
try
lnext
catch /:E553:/
lfirst
catch /:E\%(42\|776\):/
echo "Location list empty"
catch /.*/
echo v:exception
endtry
endfunction
nnoremap <silent> <Plug>LocationPrevious :<C-u>exe 'call <SID>LocationPrevious()'<CR>
nnoremap <silent> <Plug>LocationNext :<C-u>exe 'call <SID>LocationNext()'<CR>
nmap <silent> E[ <Plug>LocationPrevious
nmap <silent> E] <Plug>LocationNext
"""""""""""""
" UltiSnips "
"""""""""""""
" 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>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsEditSplit="vertical"
set tags+=./.tags
"""""""""""""
" vim-dutyl "
"""""""""""""
" Also USE https://github.com/BitR/ycmd-dcd for YCM
let g:dutyl_stdImportPaths=['~/workspace/dlang/code/druntime/import/', '~/workspace/dlang/code/phobos/']
call dutyl#register#tool('dcd-client', '/home/edis/.vim/bundle/DCD/bin/dcd-client')
call dutyl#register#tool('dcd-server', '/home/edis/.vim/bundle/DCD/bin/dcd-server')
nnoremap <F10> :DUvjump<CR>
nnoremap <F11> :DUddoc<CR>
let mapleader = ";"
call camelcasemotion#CreateMotionMappings('<leader>')
""""""""""""
" deoplete "
""""""""""""
"let g:deoplete#enable_at_startup = 1
"let g:deoplete#sources#d#dcd_client_binary = '/home/student/DCD/bin/dcd-client'
"let g:deoplete#sources#d#dcd_server_binary = '/home/student/DCD/bin/dcd-server'
"let g:deoplete#sources#d#dcd_server_autostart = 1
"let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang-3.8.so.1'
"let g:deoplete#sources#clang#clang_header = '/usr/lib/clang/3.8/include/'
"autocmd CompleteDone * pclose!
"""""""""
" Extra "
"""""""""
" Wrap a word in "
nnoremap <leader>" viw<esc>a"<esc>bi"<esc>lel
" Wrap a word in comments using NerdCommenter
"nnoremap <leader>/ viw<esc>a*/<esc>bbi/*<esc>lell
nmap <leader>/ viw<leader>ccf<space>
" Select inside next parentheses
onoremap in( :<c-u>normal! f(vi(<cr>
" Select inside last parentheses
onoremap il( :<c-u>normal! F)vi(<cr>
" Search reg S and replace with reg R
cmap <leader>r s/<c-r>s/<c-r>r/gc
" Save current word into search reg S
nnoremap <leader>ss viw"sy
" Save current word into replace reg R
nnoremap <leader>sr viw"ry
" Save sessions on quit
let g:startify_session_persistence = 1