-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.plug
329 lines (253 loc) · 9.57 KB
/
vimrc.plug
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
" Plug {{{1
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
if !filereadable(vimplug_exists)
if !executable("curl")
echoerr "You have to install curl or first install vim-plug yourself!"
execute "q!"
endif
echo "Installing Vim-Plug..."
echo ""
silent !\curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let g:not_finish_vimplug = "yes"
autocmd VimEnter * PlugInstall
endif
" Required:
call plug#begin(expand('~/.vim/plugged'))
" }}}
Plug 'tpope/vim-repeat'
" Sidebar {{{1
Plug 'Xuyuanp/nerdtree-git-plugin' | Plug 'scrooloose/nerdtree'
map <leader>e :NERDTreeToggle<CR>
let g:NERDTreeQuitOnOpen=1
" universal-ctags is recommended
Plug 'majutsushi/tagbar'
nmap <silent> t :TagbarOpenAutoClose<CR>
" https://github.com/jstemmer/gotags
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" }}} Sidebar
" Edit assistant {{{1
Plug 'bkad/CamelCaseMotion'
omap <silent> iw <Plug>CamelCaseMotion_iw
xmap <silent> iw <Plug>CamelCaseMotion_iw
" provides mappings to easily delete, change and add such surroundings in pairs
Plug 'tpope/vim-surround'
" Insert or delete brackets, parens, quotes in pair
Plug 'jiangmiao/auto-pairs'
" disable Map <CR> to insert a new indented line if cursor in (|), {|} [|], '|', "|"
" pls refer to keymap below with ncm2 and UltiSnips
let g:AutoPairsMapCR=0
Plug 'terryma/vim-multiple-cursors'
" insert mode: c-v
Plug 'cyansprite/Extract'
" the number of yanks you want to save
let g:extract_maxCount=10
Plug 'mbbill/undotree'
nnoremap <leader>u :UndotreeToggle<CR>
let g:undotree_SetFocusWhenToggle=1
Plug 'tpope/vim-commentary'
" }}}
" Completion {{{1
" ncm2 requires nvim-yarp
Plug 'ncm2/ncm2' | Plug 'roxma/nvim-yarp'
" enable ncm2 for all buffer
autocmd BufEnter * call ncm2#enable_for_buffer()
" Plug 'ncm2/float-preview.nvim'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-ultisnips' | Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger = "<C-u>" " less used because of keymap below
Plug 'honza/vim-snippets'
let g:LanguageClient_hasSnippetSupport=1
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
let g:LanguageClient_serverCommands = {
\ 'go': ['go-langserver', '-gocodecompletion', '-diagnostics', '-lint-tool', 'golint' ],
\ 'c': ['clangd'],
\ }
augroup LanguageClient_keymap
autocmd!
autocmd User LanguageClientStarted nnoremap <silent> <cr> :call LanguageClient#textDocument_hover()<CR>
autocmd User LanguageClientStarted nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
autocmd User LanguageClientStarted nnoremap <silent> <leader>lx :call LanguageClient#textDocument_references()<CR>
autocmd User LanguageClientStarted nnoremap <silent> <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
autocmd User LanguageClientStarted nnoremap <silent> <leader>lr :call LanguageClient#textDocument_rename()<CR>
autocmd BufWritePre *.go :call LanguageClient#textDocument_formatting_sync()
augroup END
" }}} Completion
" Search & Explore {{{1
Plug 'easymotion/vim-easymotion'
" Disable default mappings
let g:EasyMotion_do_mapping = 0
" makes EasyMotion work similarly to Vim's smartcase for global searches
let g:EasyMotion_smartcase = 1
" n-character search motion
" use <Tab> and <S-Tab> to scroll down/up a page
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
" By default, CtrlSF use working directory as search path when no path is specified
Plug 'dyng/ctrlsf.vim'
map <leader>/ :CtrlSFToggle<cr>
nmap <leader>f <Plug>CtrlSFCwordPath
vmap <leader>f <Plug>CtrlSFVwordExec
" ripgrep
if executable('rg')
let g:ctrlsf_ackprg = 'rg'
" explictly set FZF_DEFAULT_COMMAND to avoid GUI does not know it
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
map <leader>s :Find<space>
" command! -bang -nargs=* GGrep
" \ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
endif
" it use FZF_DEFAULT_COMMAND to find files
if isdirectory('/usr/local/opt/fzf') " Mac/brew
Plug '/usr/local/opt/fzf'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
endif
Plug 'junegunn/fzf.vim'
nnoremap <silent> <leader>o :FZF +m --prompt=Files><CR>
nnoremap <silent> <leader><space> :Buffers<CR>
nnoremap <silent> <leader>m :Marks<CR>
" }}}
" Color scheme and Highlight {{{1
" colorscheme
Plug 'morhetz/gruvbox'
Plug 'sickill/vim-monokai'
" many themes, inlucde base16-monokai, base16-gruvbox
Plug 'chriskempson/base16-vim'
" all trailing whitespace characters (spaces and tabs)
" :StripWhitespace --- clean whitespace painless
Plug 'ntpeters/vim-better-whitespace'
" showing different levels of parentheses in different colors
Plug 'luochen1990/rainbow'
let g:rainbow_active = 1
" highlight text yanked
Plug 'machakann/vim-highlightedyank'
" displaying thin vertical lines at each indentation level for code indented
" with spaces. patching font to get better visual
Plug 'Yggdroot/indentLine'
" don't hide quotes for json files
let g:indentLine_fileTypeExclude = ['json']
Plug 'ap/vim-css-color'
" }}} Color scheme
" Status Line {{{
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = "unique_tail"
" airline need it to show branch
" it also load tags under .git if it does exist
Plug 'tpope/vim-fugitive'
" }}} Status Line
" Git {{{1
" shows a git diff in the gutter
Plug 'airblade/vim-gitgutter'
let g:gitgutter_map_keys = 0
" jump between hunks:
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
" }}}
" Tmux {{{1
" move between Vim panes and tmux splits seamlessly
Plug 'christoomey/vim-tmux-navigator'
" vim-tmux-clipboard automatically copy yanked text into tmux's clipboard, and
" copy tmux's clipboard content into vim's quote(") register
" Plug 'roxma/vim-tmux-clipboard'
Plug 'wellle/tmux-complete.vim'
" Just start vim inside of tmux. airline's colors will be applied to tmux's
" statusline
Plug 'edkolev/tmuxline.vim'
" }}}
" Kepmap for ncm2, UltiSnips, auto-pairs {{{1
" When popup visible, <Tab> acts like <C-n> wich selects next completion item
" from the list. If there is no popup then <Tab> acts as jump to next snippet
" placeholder, if we actually editing a snippet. If no popup and no snippet
" <Tab> acts like <Tab>
function! SmartTab()
if pumvisible()
return "\<c-n>"
else
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<Tab>"
endif
endif
endfunction
" The same as previous, but selects previous item and jumps backwards. Or
" acts like <S-Tab>
function! SmartSTab()
if pumvisible()
return "\<c-p>"
else
let snippet = UltiSnips#JumpBackwards()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<S-Tab>"
endif
endfunction
function! ExpandOrJumpOrClosePopup()
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<c-y>" "close popup menu
endif
endfunction
snoremap <silent><Tab> <Esc>:call UltiSnips#JumpForwards()<CR>
snoremap <silent><S-Tab> <Esc>:call UltiSnips#JumpBackwards()<CR>
inoremap <silent><S-Tab> <C-R>=SmartSTab()<CR>
inoremap <silent><Tab> <C-R>=SmartTab()<CR>
" if no popup menu, Insert new indented line after return if cursor in blank brackets or quotes.
" if popup menu is visible, try dynamic (e.g. function parameter expansion from LSP) and static snippet, or jump, or close popup menu
imap <expr> <CR> (pumvisible() ? "\<C-y>\<Plug>(expand_or_jump_or_close)" : "\<CR><C-R>=AutoPairsReturn()<CR>")
imap <expr> <Plug>(expand_or_jump_or_close) ( ncm2_ultisnips#completed_is_snippet() ? "\<Plug>(ncm2_ultisnips_expand_completed)" : "\<C-R>=ExpandOrJumpOrClosePopup()<CR>")
" functionality is same as above
" ncm2_ultisnips#expand_or: expand dynamic snippet first
" inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or(pumvisible()? "\<C-R>=ExpandOrJumpOrClosePopup()<CR>":"\<CR><C-R>=AutoPairsReturn()<CR>", 'n')
" }}}
" autoload vimrc.plug
au! bufwritepost *vimrc.plug source ~/.vimrc.plug
if filereadable(expand("~/.vimrc.plug.local"))
source ~/.vimrc.plug.local
endif
call plug#end()
" vim: set foldlevel=0 foldmethod=marker: