-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
362 lines (286 loc) · 9.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
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
" Make vim portable.
if ($OS == 'Windows_NT')
" Windows specific settings
let $HOME=$VIM
endif
" Load and run pathogen.
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
" key binding for initializing youcomplete manually
" the plugin takes too much time to start, so let's initialize it only when necessary
noremap <F1> :call youcompleteme#Enable()<CR>
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin
set nobackup
set noundofile
set nowritebackup
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set relativenumber
function! NumberToggle()
if(&relativenumber == 1)
set number
set norelativenumber
else
set nonumber
set relativenumber
endif
endfunc
nnoremap <F7> :call NumberToggle()<cr>
syntax on
set term=xterm
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
if ($TERM == 'xterm-256color')
set t_Co=256
let g:onedark_termcolors=256
else
set t_Co=16
let g:onedark_termcolors=16
endif
colorscheme onedark
let g:airline_theme='onedark'
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
au BufRead,BufNewFile *.as set filetype=actionscript
" set default font
if ($OS == 'Windows_NT')
" Windows specific settings
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h10
else
" Unix specific settings
set guifont=Roboto\ Mono\ for\ Powerline\ 10
endif
"Personal Settings.
"More to be added soon.
filetype plugin indent on
syntax on
set laststatus=2
set encoding=utf8
" air-line
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols = {}
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.maxlinenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = '∄'
let g:airline_symbols.whitespace = 'Ξ'
" powerline 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 = ''
let g:airline#extensions#tabline#enabled = 1
set foldlevelstart=99
inoremap <Char-0x07F> <BS>
nnoremap <Char-0x07F> <BS>
set autowriteall
set hidden
au BufLeave * upd
au BufLeave,FocusLost * silent! wall
au BufNewFile,BufRead *.groovy setf groovy
nnoremap <Tab> <c-w>w
nnoremap <bs> <c-w>W
noremap <silent> <C-S> :update<CR>
vnoremap <silent> <C-S> <C-C>:update<CR>
inoremap <silent> <C-S> <C-O>:update<CR>
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
set ignorecase
set smartcase
set textwidth=120
command Greview :Git! diff --cached
nnoremap <F4> "=strftime("%a, %d %b %Y %H:%M:%S")<CR>P
inoremap <F4> <C-R>=strftime("%a, %d %b %Y %H:%M:%S")<CR>
set columns=200
au GUIEnter * simalt ~x
command! -nargs=* Wrap set wrap linebreak nolist
" signify plugin settings
let g:signify_sign_show_count = 0
let g:signify_sign_change = '~'
let g:signify_vcs_list = [ 'git' ]
" use slash instead of backslash as path separator in windows
set shellslash
" ack plugin settings for search using ag
let g:ackprg = 'ag --nogroup --nocolor --column'
let g:ackhighlight = 1
" Use space bar as a leader key
let mapleader = "\<Space>"
nnoremap <Space> <Nop>
" Do not move cursor when switching tabs
set nostartofline
" CtrlP plugin settings
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site)$',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$',
\}
" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is in version
" control. It also supports works with .svn, .hg, .bzr.
let g:ctrlp_working_path_mode = 'r'
" Use a leader instead of the actual named binding
nmap <leader>o :CtrlP<cr>
" Easy bindings for its various modes
nmap <leader>bb :CtrlPBuffer<cr>
nmap <leader>bm :CtrlPMixed<cr>
nmap <leader>bs :CtrlPMRU<cr>
" Buffer key bindings
" This allows buffers to be hidden if you've modified a buffer.
" This is almost a must if you wish to use buffers in this way.
set hidden
" To open a new empty buffer
" This replaces :tabnew which I used to bind to this mapping
nmap <leader>T :enew<cr>
" Move to the next buffer
nmap <leader>l :bnext<CR>
" Move to the previous buffer
nmap <leader>h :bprevious<CR>
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
nmap <leader>bq :bp <BAR> bd #<CR>
" Show all open buffers and their status
nmap <leader>bl :ls<CR>
" show jsdoc popup window on the bottom, otherwise it shows up at the top and shifts current buffer down
set splitbelow
" key bindings for ack search
nnoremap <leader>a :Ack
vnoremap <Leader>a y:Ack <C-r>=fnameescape(@")<CR><CR>
" key bindings for vim-expand-region
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" settings and key bindings for browserlink and slime plugins
let g:bl_no_autoupdate = 1
let g:slime_target = "conemu"
let g:codeeval = "browserlink"
function! SlimeBufferSend()
let save_cursor = getpos(".")
exec "1,$SlimeSend"
call setpos('.', save_cursor)
endfunc
function! CodeevalToggle()
if(g:codeeval == "browserlink")
let g:codeeval = "slime"
nmap <silent><leader>r <Plug>SlimeParagraphSend
xmap <silent><leader>r <Plug>SlimeRegionSend
nmap <silent><leader>R :call SlimeBufferSend()<CR>
else
let g:codeeval = "browserlink"
vmap <silent><Leader>r :BLEvaluateSelection<CR>
nmap <silent><Leader>r :BLEvaluateParagraph<CR>
nmap <silent><Leader>R :BLEvaluateBuffer<CR>
endif
endfunc
call CodeevalToggle()
call CodeevalToggle()
nnoremap <F9> :call CodeevalToggle()<cr>
" mapped jj to escape
ino jj <esc>
cno jj <c-c>
" Use gvim for fugitive when it is called from gvim.
" Otherwise vim is called from Git MSYS console, which breaks xterm colors.
if has("gui_running")
let g:fugitive_git_executable = 'set GIT_EDITOR=gvim && git'
endif
" do not map default bindings for windowswap, since <leader>pw slows down <leader>p that is preferrable for NERDTree
" <leader>pw is deprecated anyways
let g:windowswap_map_keys = 0
nnoremap <silent> <leader>ww :call WindowSwap#EasyWindowSwap()<CR>
" key bindings for NERDTree
nmap <silent> <Leader>p :NERDTreeToggle<CR>
" disable left-hand scroll in gui vim, since it causes gvim window to jump and resize
" when NERDTree shows up
:set guioptions-=L
" Map the Y key to y$, so that it behaves the same as D and C.
" This should happen after yankstack plugin is initialized.
call yankstack#setup()
nmap Y y$
" Make it possible to use Alt-.. combinations in gvim. By default they are bound to menus.
set winaltkeys=no
" Disable autopairs Alt-P mapping, so it could be used by yankstack plugin.
let g:AutoPairsShortcutToggle = ''
" key bindings for search highlight removing
map <silent> <leader><cr> :noh<cr>
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ag \"" . l:pattern . "\" " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
" Yank to clipboard by default.
" From http://stackoverflow.com/questions/13380643/vim-use-as-default-register-only-for-yank-command
:nnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
:nnoremap <expr> yy (v:register ==# '"' ? '"+' : '') . 'yy'
:nnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
:xnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
:xnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'