This repository has been archived by the owner on Mar 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
314 lines (276 loc) · 8.54 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
set nocompatible
let g:EclimCompletionMethod='omnifunc'
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
au BufWinEnter,BufNewFile * silent tab
setlocal textwidth=100
set colorcolumn=101
au BufEnter <buffer> set colorcolumn=101
set textwidth=100
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>100v.\+', -1)
set encoding=utf-8
" syntax
" define <Leader>
let mapleader=";"
syntax enable
syntax on
" display line number
set number
" detect filetype
filetype on
filetype indent on
filetype plugin on
" set color theme
set t_Co=256
set background=dark
let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
colorscheme dusk
" no cursor blinking
" set gcr=a:block-blinkon0
" show status
set laststatus=2
" code folding
" set foldmethod=indent
"set foldmethod=syntax
set foldmethod=indent
" auto start code folding
set nofoldenable
" for .hql files
au BufNewFile,BufRead *.hql set filetype=hive expandtab
" for .q files
au BufNewFile,BufRead *.q set filetype=hive expandtab
" block from linux custom begins
" do not display nonreadable chars
set nolist
" display coordinate info
set ruler
" display command info
set showcmd
" highlight the current line
set cursorline
" set cursorcolumn
" quick jump to the matched parenthesis
" set showmatch
" highlight the unmatched parenthesis
let loaded_matchparen=1
" highlight the matched pattern
set hlsearch
" block from linux custom ends
" block from linux custom begins
" find the lines with blanks at end (fs -> find space)
map <leader>fs :/.*\s\+$<CR>
" delete the blanks at the line end (res -> remove end space)
map <leader>res :s#\s\+$##<CR>
" block from linux custom ends
map <leader>z zazR
" no highlight
map <Leader>nh :nohl<CR>
" shortcuts for line begining and end nmap lb ^
nmap lb ^
nmap le $
" copy to X buffers
vnoremap <Leader>y "+y
" paste from X buffers
nmap <Leader>p "+p
" exit current window
nmap <Leader>q :q<CR>
" save current window
nmap <Leader>w :w<CR>
" save all window and exit vim
nmap <Leader>WQ :wa<CR>:q<CR>
" force to quit vim
nmap <Leader>Q :qa!<CR>
" next window
nnoremap <Leader>nw <C-W><C-W>
" jump to the right window
nnoremap <Leader>lw <C-W>l
" jump to the left window
nnoremap <Leader>hw <C-W>h
" jump to the upper window
nnoremap <Leader>kw <C-W>k
" jump to the lower window
nnoremap <Leader>jw <C-W>j
" jump between pairs of parenthesiss
" pa -> pair
nmap <Leader>pa %
" jump to next word
nmap <Leader>n *
" jump to previous word
nmap <Leader>p #
" turn on real-time search
set incsearch
" get case insensitive during search
set ignorecase
" turn of compatible mode
set nocompatible
" smart complete
set wildmenu
" specify path for pathogen
runtime bundle/pathogen/autoload/pathogen.vim
" run pathogen
execute pathogen#infect()
" skip parenthesiss
func SkipPair()
if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'" || getline('.')[col('.') - 1] == '}' || getline('.')[col('.') - 1] == '>' || getline('.')[col('.') - 1] == '|'
return "\<ESC>la"
else
return "\t"
endif
endfunc
inoremap <Leader>a <c-r>=SkipPair()<CR>
" manual append parenthesis
func ClosePairs()
if getline('.')[col('.') - 2] == '('
return ")\<ESC>i"
elseif getline('.')[col('.') - 2] == '['
return "]\<ESC>i"
elseif getline('.')[col('.') - 2] == '{'
return "}\<ESC>i"
elseif getline('.')[col('.') - 2] == "\'"
return "\"\<ESC>i"
elseif getline('.')[col('.') - 2] == "\""
return "\"\<ESC>"
else
return ""
endif
endfunc
inoremap <Leader>v <c-r>=ClosePairs()<CR>
" configs for vim-signature
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "m-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "mda",
\ 'PurgeMarkers' : "m<BS>",
\ 'GotoNextLineAlpha' : "']",
\ 'GotoPrevLineAlpha' : "'[",
\ 'GotoNextSpotAlpha' : "`]",
\ 'GotoPrevSpotAlpha' : "`[",
\ 'GotoNextLineByPos' : "]'",
\ 'GotoPrevLineByPos' : "['",
\ 'GotoNextSpotByPos' : "mn",
\ 'GotoPrevSpotByPos' : "mp",
\ 'GotoNextMarker' : "[+",
\ 'GotoPrevMarker' : "[-",
\ 'GotoNextMarkerAny' : "]=",
\ 'GotoPrevMarkerAny' : "[=",
\ 'ListLocalMarks' : "ms",
\ 'ListLocalMarkers' : "m?"
\ }
" traverse the named tags
nmap <Leader>tn :tnext<CR>
nmap <Leader>tp :tprevious<CR>
" syntax check
nmap <Leader>sy :SyntasticToggleMode<CR>
nmap <Leader>sc :SyntasticCheck<CR>
" function to replace. args:
" confirm: whether to confirm before replacement
" wholeword: to match wholeword
" replace: string to replace
function! Replace(confirm, wholeword, replace)
wa
let flag = ''
if a:confirm
let flag .= 'gec'
else
let flag .= 'ge'
endif
let search = ''
if a:wholeword
let search .= '\<' . escape(expand('<cword>'), '/\.*$^~[') . '\>'
else
let search .= expand('<cword>')
endif
let replace = escape(a:replace, '/\&~')
execute 'argdo %s/' . search . '/' . replace . '/' . flag . '| update'
endfunction
" no confirm, not wholeword
nnoremap <Leader>R :call Replace(0, 0, input('Replace '.expand('<cword>').' with: '))<CR>
" not confirm, wholeword
nnoremap <Leader>rw :call Replace(0, 1, input('Replace '.expand('<cword>').' with: '))<CR>
" confirm, not wholeword
nnoremap <Leader>rc :call Replace(1, 0, input('Replace '.expand('<cword>').' with: '))<CR>
" confirm and wholeword
nnoremap <Leader>rcw :call Replace(1, 1, input('Replace '.expand('<cword>').' with: '))<CR>
nnoremap <Leader>rwc :call Replace(1, 1, input('Replace '.expand('<cword>').' with: '))<CR>
" code template
let g:UltiSnipsSnippetDirectories=["mysnippets"]
let g:UltiSnipsExpandTrigger="<leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<leader><tab>"
let g:UltiSnipsJumpBackwardTrigger="<leader><s-tab>"
" use NERDTree. fl -> file list
nmap <Leader>fl :NERDTreeToggle<CR>
" set window width
let NERDTreeWinSize=32
" set window position
let NERDTreeWinPos="right"
" display hidden file
let NERDTreeShowHidden=0
" no redundant info
let NERDTreeMinimalUI=1
" remove buffer
let NERDTreeAutoDeleteBuffer=1
" show/hide MiniBufExplorer window
map <Leader>bl :MBEToggle<cr>
" shortcut for switch
map <Leader>bn :MBEbn<cr>
map <Leader>bp :MBEbp<cr>
map <Leader>bd :MBEbd<cr>
" setup for environment saving
set sessionoptions="blank,buffers,globals,localoptions,tabpages,sesdir,folds,help,options,resize,winpos,winsize"
" save undo history
set undodir=~/.undo_history/
set undofile
" shortcut for saving environment
map <leader>ss :mksession! my.vim<cr> :wviminfo! my.viminfo<cr>
" shortcut for restoring environment
map <leader>rs :source my.vim<cr> :rviminfo my.viminfo<cr>
" deploy the gundo tree
nnoremap <Leader>ud :GundoToggle<CR>
" color theme for YcmCompleter
" menu
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
" items
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
" toggle for trailing whitespaces highlights
map <Leader>tw :ToggleWhitespace<cr>
" ctrlp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_mruf_case_sensitive = 0
let g:ctrlp_max_files = 100000
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
let g:ctrlp_regexp = 1
let g:ctrlp_open_multiple_files = 'v'
" disable preview scratch window
set completeopt-=preview
" use ag for ack in vim
let g:ackprg = 'ag --nogroup --nocolor -i'
map <Leader>d :Ack <cword><CR>
map <Leader>s :!ag -C 3 --ruby --js --sass --color-match "1;31" --color-line-number "39" <cword><CR>
map <Leader>ra <C-W><C-W>q
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist|\.vagrant|log|logs|tmp|CVS|coverage|vendor)|(\.(swp|ico|git|svn))$'
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'
let g:ycm_warning_symbol = '.'
let g:ycm_error_symbol = '..'
let g:ycm_server_use_vim_stdout = 1
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()