-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
252 lines (198 loc) · 5.81 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
call plug#begin('~/.vim/plugged')
"" Misc {{{
let mapleader=" "
if (has("win32"))
set encoding=utf-8
set fileencodings=utf-8
endif
set directory=/tmp
syntax on
filetype plugin indent on
nnoremap <leader>w :w<cr>
nnoremap <leader>q :q<cr>
nnoremap <leader>wq :wq<cr>
nnoremap <leader>m :on<cr>
nnoremap <leader>e :e!<cr>
set showmatch
set mat=2
set showcmd
set hidden
set splitright
inoremap <left> <nop>
inoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
nnoremap gV `[v`]
nnoremap <leader>ev :e $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
Plug 'vim-scripts/DrawIt'
Plug 'christoomey/vim-tmux-navigator'
"}}}
"" GUI {{{
if (has("gui"))
set go-=m
set go-=T
set go-=r
set go-=R
set go-=l
set go-=L
set guifont=Consolas:h15
set autoread
endif
colorscheme wombat
set laststatus=2
set statusline=%F%m%r%w\ %{fugitive#statusline()}\ [%l,%v]\ [%{&ff}]\ [%{&ft}]
"}}}
"" Navigation {{{
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap tn :tabn<cr>
nnoremap tp :tabp<cr>
Plug 'gcmt/taboo.vim'
"}}}
"" Tabstop {{{
set tabstop=4
set shiftwidth=4
set noexpandtab
augroup two_tab_indent
au!
autocmd FileType xml,html,json setlocal tabstop=2 | setlocal shiftwidth=2
augroup END
"}}}
"" Folding {{{
set foldenable
augroup folding
au!
au FileType vimwiki setlocal foldlevel=1
au FileType vim setlocal foldmethod=marker | setlocal foldlevel=0
au FileType java setlocal foldmethod=syntax | setlocal foldlevel=1 | setlocal nofoldenable
au FileType java nnoremap <buffer> zo zO
augroup end
"}}}
"" Search {{{
set incsearch
set hlsearch
set ignorecase
set nowrapscan
hi Search cterm=NONE ctermfg=black ctermbg=gray
Plug 'romainl/vim-cool'
""search hilight text in visual mode
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" grep setting
set grepprg=ag\ --nogroup\ --nocolor
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
augroup autoquickfix
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
autocmd FileType qf nnoremap <buffer> <C-x> <C-w><Enter>
autocmd FileType qf nnoremap <buffer> <C-v> <C-w><Enter><C-w>L
augroup END
"" }}}
"" Editing {{{
set autowrite
inoremap <C-l> <esc>b~ea
function! DeleteTrailingWS()
execute 'normal! mz'
execute '%s/\s\+$//e'
execute "normal! `z"
endfunction
augroup clear_trail_white_space
au!
au BufWritePre * :call DeleteTrailingWS()
augroup END
packadd! matchit
Plug 'SirVer/ultisnips'
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnipsEditSplit="vertical"
Plug 'hotoo/pangu.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-abolish'
Plug 'terryma/vim-multiple-cursors'
let g:multi_cursor_quit_key='<C-c>'
nnoremap <C-c> :call multiple_cursors#quit()<CR>
Plug 'easymotion/vim-easymotion'
map <Plug>(easymotion-prefix)w <Plug>(easymotion-bd-w)
map <Plug>(easymotion-prefix)e <Plug>(easymotion-bd-e)
map <Plug>(easymotion-prefix)l <Plug>(easymotion-lineforward)
map <Plug>(easymotion-prefix)h <Plug>(easymotion-linebackward)
Plug 'vim-scripts/fcitx.vim'
set ttimeoutlen=100
Plug 'jiangmiao/auto-pairs'
set sessionoptions+=globals
Plug 'tpope/vim-obsession'
"}}}
"" Project Manager {{{
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
nnoremap <leader>fe :NERDTreeToggle<cr>
nnoremap <leader>ff :NERDTreeFind<cr>
Plug 'kien/ctrlp.vim'
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/target/*,*/node_modules/*
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_root_markers = ['.root']
Plug 'tpope/vim-fugitive'
nnoremap <leader>gs :Gstatus<cr>
"}}}
"" Langauage {{{
"" Front Develop {{{
Plug 'posva/vim-vue'
augroup two_spaces_indent
au!
autocmd FileType scss,vue,javascript,yaml,css setlocal expandtab | setlocal tabstop=2 | setlocal shiftwidth=2
augroup END
Plug 'othree/html5.vim'
Plug 'mattn/emmet-vim' , { 'for': ['xml', 'html', 'jsp', 'js', 'vue'] }
Plug 'leafgarland/typescript-vim'
"}}}
"" Java {{{
let g:EclimLoggingDisabled=1
augroup java
au!
au FileType java nnoremap <buffer> <leader>o :call eclim#java#import#OrganizeImports()<cr>
au FileType java nnoremap <buffer> <leader>i :call eclim#java#correct#Correct()<cr>
au FileType java nnoremap <buffer> gd :JavaSearch -x declarations<cr>
au FileType java nnoremap <buffer> gi :JavaSearch -x implementors<cr>
au FileType java inoremap <buffer> <c-d> <c-x><c-u>
augroup END
function! ChangeToJavaRoot()
let currentDir = expand('%:p:h')
while findfile('.root', currentDir) != '.root'
exec 'lcd' fnamemodify(currentDir, ':h')
let currentDir = fnamemodify(currentDir, ':h')
endwhile
endfunction
" Plug 'ycm-core/YouCompleteMe'
" let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
" let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" augroup java
" au!
" au FileType java nnoremap <buffer> <leader>o :YcmCompleter OrganizeImports<cr>
" au FileType java nnoremap <buffer> <leader>i :YcmCompleter FixIt<cr>
" au FileType java nnoremap <buffer> gd :YcmCompleter GoToDeclaration<cr>
" au FileType java nnoremap <buffer> gi :YcmCompleter GoToDefinition<cr>
" au FileType java inoremap <buffer> <c-d> <c-x><c-u>
" augroup END
"}}}
"}}}
"" Document {{{
Plug 'vimwiki/vimwiki'
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
nnoremap <leader>tt :VimwikiToggleListItem<cr>
Plug 'masukomi/vim-markdown-folding'
"}}}
call plug#end()