-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvimrc
230 lines (199 loc) · 6.56 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
" vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'ycm-core/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-commentary'
Plugin 'bling/vim-airline'
Plugin 'mrtazz/DoxygenToolkit.vim'
Plugin 'SirVer/ultisnips'
Plugin 'rizzatti/dash.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-unimpaired'
Plugin 'shumphrey/fugitive-gitlab.vim'
Plugin 'junegunn/vim-easy-align'
Plugin 'scrooloose/nerdtree'
Plugin 'Raimondi/delimitMate'
Plugin 'tpope/vim-surround'
Plugin 'vimwiki/vimwiki'
Plugin 'nelstrom/vim-visual-star-search'
Plugin 'tpope/vim-repeat'
Plugin 'skywind3000/asyncrun.vim'
call vundle#end()
filetype plugin indent on
" more convenient to reach leader key
let mapleader = ","
" colorscheme
colorscheme Tomorrow-Night-Eighties
" search highlight
set hlsearch
nnoremap <silent> <leader>i :nohl<CR>
" set ctags
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <C-w>\ :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
map <F10> :!gotags -R . > ./tags <CR>
map <F12> :!ctags -R .<CR>
" reformat file
map <F7> mzgg=G`z<CR>
" move between windows
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-l> :wincmd l<CR>
" air line
let g:airline_theme = 'dark'
set laststatus=2
set t_Co=256
" ycm
let g:ycm_register_as_syntastic_checker = 0
let g:ycm_filetype_specific_completion_to_disable = {"python": 1}
" syntastics
" for python flake8 should be installed: pip install flake8
let g:syntastic_cpp_compiler = "g++ -std=c++11"
let g:syntastic_check_on_w = 1
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_loc_list_height = 4
let g:syntastic_cpp_remove_include_errors = 1
let g:syntastic_python_flake8_args='--ignore=E501,E302,E251,E221,E402,E266,E226'
let g:syntastic_mode_map = { 'passive_filetypes': ['java'] }
" doxygentoolkit
let g:DoxygenToolkit_fileTag = "@file "
let g:DoxygenToolkit_briefTag_pre = "@brief "
let g:DoxygenToolkit_paramTag_pre = "@param "
let g:DoxygenToolkit_returnTag = "@returns "
let g:DoxygenToolkit_versionTag = "@version "
let g:DoxygenToolkit_authorTag = "@author "
let g:DoxygenToolkit_dateTag = "@date "
let g:DoxygenToolkit_authorName = "Wang Jiajun <[email protected]>"
let g:doxygen_enhanced_color = 1
" go to tab by number
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
let g:lasttab = 1
nmap <Leader>l :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" ultisnips
let g:UltiSnipsExpandTrigger = "<c-l>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
" paste without indentation
set pastetoggle=<C-y>
" git
let g:fugitive_gitlab_domains = ['https://git.elenet.me']
" easy align
" start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" nerdtree
map <F5> :NERDTreeToggle<CR>
" for hive script
filetype plugin on
autocmd BufNewFile,BufRead *.hive set filetype=sql | set filetype=hive
let g:sh_no_error = 1
let g:ftplugin_sql_omni_key = '<C-x>'
" ultisnippets
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips'
" delimitmate
let delimitMate_expand_space = 1
let delimitMate_expand_cr = 1
" vimwiki
let wiki = {}
let wiki.path = '~/.vim/vimwiki/wiki'
let wiki.nested_syntaxes = {'python': 'python', 'cpp': 'cpp', 'plain': 'plain'}
let wiki.template_path = '~/.vim/vimwiki/template'
let wiki.template_default = 'default'
let wiki.css_name = 'github.css'
let g:vimwiki_list = [wiki]
nnoremap <leader>wc :VimwikiAll2HTML<CR>
nnoremap <leader>wf :VimwikiTable<CR>
" show invisible character
nnoremap <silent> <leader>l :set list!<CR>
set listchars=tab:▸\ ,eol:¬
" tab width
autocmd FileType cpp set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
autocmd FileType css set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
autocmd FileType hive set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
autocmd FileType sql set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
" preserve state function
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nnoremap <leader>rt :call Preserve("%s/\\s\\+$//e")<CR>
nnoremap <leader>= :call Preserve("normal gg=G")<CR>
" select all
nnoremap <leader>a ggVG
" quickly edit and apply vimrc
nnoremap <leader>ve :edit ~/.vim/vimrc<CR>
nnoremap <leader>va :let @/=""<CR>:w<CR>:source ~/.vim/vimrc<CR>
" quickly install bundle plugin
nnoremap <leader>p :PluginInstall<CR>
" render markdown
" prerequisites: brew install pandoc node.js
" npm install -g browser-sync
function! MdPath()
return "~/.vim/vimwiki/wiki_html/".expand("<afile>:t:r").".html"
endfunction
function! MdRender()
execute "silent !pandoc --standalone -c github.css ".expand("<afile>")." -o ".MdPath()" >& /dev/null"
endfunction
function! MdSync()
execute "silent !~/.vim/vimwiki/wiki_html/browser-sync.sh ".MdPath()." start"
endfunction
function! MdEndSync()
execute "silent !~/.vim/vimwiki/wiki_html/browser-sync.sh ".MdPath()." stop"
endfunction
function! MdRemove()
execute "silent !rm ".MdPath()
endfunction
nnoremap <leader>r :redraw!<CR>
autocmd BufWinEnter,BufNewFile *.md execute ":w" | call MdRender() | call MdSync()
autocmd BufWritePost *.md call MdRender()
autocmd BufWinLeave *.md call MdEndSync() | call MdRemove()
" manage git
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gp :Gpush<CR>
nnoremap <leader>gf :Git push --force<CR>
nnoremap <leader>gd :Gdiff<CR>
nnoremap <leader>gr :Gread<CR>
nnoremap <leader>gw :Gwrite<CR>
nnoremap <leader>gc :Gcommit<CR>
nmap <leader>gb <leader>gs:Gbrowse<CR>ZZ
" show time when coding
nmap <silent> <leader>t :echo substitute(system('date +%T'),'\n','','')<CR>
" async run
nnoremap <leader>mb :AsyncRun make -j4<CR>
nnoremap <leader>mc :AsyncStop<CR>
nnoremap <leader>mo :copen 4<CR>
nnoremap <leader>mr :AsyncRun
syntax on
set backspace=2
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
set smartindent
set number
set mouse=a
set textwidth=0
set completeopt=menu
set clipboard+=unnamed