-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvimrc.plugins
385 lines (355 loc) · 13.1 KB
/
nvimrc.plugins
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
" Autoinstall vim-plug {{{
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" }}}
call plug#begin('~/.config/nvim/plugged') " Plugins initialization start {{{
" }}}
" Appearance ==================================================================
Plug 'nanotech/jellybeans.vim' " color scheme
" {{{
let g:jellybeans_use_term_background_color = 0
" }}}
Plug 'itchyny/lightline.vim' " status line
" {{{
" \ 'separator': { 'left': '▓▒░', 'right': '░▒▓' },
" \ 'colorscheme': 'jellybeans_mod',
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'gitgutter', 'filename' ] ],
\ 'right': [ [ 'percent', 'lineinfo' ],
\ [ 'syntastic' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'gitgutter': 'LightLineGitGutter',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'syntastic': 'SyntasticStatuslineFlag',
\ 'filename': 'LightLineFilename'
\ },
\ 'seperator': { 'left': '>', 'right': '' },
\ 'subseparator': { 'left': '>', 'right': '' }
\ }
function! LightLineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightLineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "RO"
else
return ""
endif
endfunction
function! LightLineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! LightLineGitGutter()
if ! exists('*GitGutterGetHunkSummary')
\ || ! get(g:, 'gitgutter_enabled', 0)
\ || winwidth('.') <= 90
return ''
endif
let symbols = [
\ g:gitgutter_sign_added,
\ g:gitgutter_sign_modified,
\ g:gitgutter_sign_removed
\ ]
let hunks = GitGutterGetHunkSummary()
let ret = []
for i in [0, 1, 2]
if hunks[i] > 0
call add(ret, symbols[i] . hunks[i])
endif
endfor
return join(ret, ' ')
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
" {{{ Modified jellybeans theme
let s:base03 = [ '#151513', 233 ]
let s:base02 = [ '#30302c', 236 ]
let s:base01 = [ '#4e4e43', 237 ]
let s:base00 = [ '#666656', 242 ]
let s:base0 = [ '#808070', 244 ]
let s:base1 = [ '#949484', 246 ]
let s:base2 = [ '#a8a897', 248 ]
let s:base3 = [ '#e8e8d3', 253 ]
let s:yellow = [ '#ffb964', 215 ]
let s:red = [ '#cf6a4c', 167 ]
let s:magenta = [ '#f0a0c0', 217 ]
let s:blue = [ '#7697D6', 4 ]
let s:orange = [ '#ffb964', 215 ]
let s:green = [ '#99ad6a', 107 ]
let s:white = [ '#FCFCFC', 15 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}, 'terminal': {}}
let s:p.normal.left = [ [ s:white, s:blue ], [ s:base3, s:base02 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base3, s:base02 ] ]
let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base02, s:orange ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base02, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.terminal.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base0, s:base03 ] ]
let s:p.inactive.middle = [ [ s:base00, s:base02 ] ]
let s:p.tabline.left = [ [ s:base3, s:base02 ] ]
let s:p.tabline.tabsel = [ [ s:white, s:blue ] ]
let s:p.tabline.middle = [ [ s:base01, s:base03 ] ]
let s:p.tabline.right = [ [ s:base03, s:base03 ], [ s:base03, s:base03 ] ]
let s:p.normal.error = [ [ s:red, s:base02 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base01 ] ]
" }}}
" }}}
Plug 'kshenoy/vim-signature' " easy marker navigation
" {{{
let g:SignatureMarkerTextHL = 'Typedef'
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "m-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "m<Space>",
\ 'PurgeMarkers' : "m<BS>",
\ 'GotoNextLineAlpha' : "",
\ 'GotoPrevLineAlpha' : "",
\ 'GotoNextSpotAlpha' : "",
\ 'GotoPrevSpotAlpha' : "",
\ 'GotoNextLineByPos' : "]'",
\ 'GotoPrevLineByPos' : "['",
\ 'GotoNextSpotByPos' : "]`",
\ 'GotoPrevSpotByPos' : "[`",
\ 'GotoNextMarker' : "[+",
\ 'GotoPrevMarker' : "[-",
\ 'GotoNextMarkerAny' : "]=",
\ 'GotoPrevMarkerAny' : "[=",
\ 'ListLocalMarks' : "m/",
\ 'ListLocalMarkers' : "m?"
\ }
" }}}
Plug 'tpope/vim-sleuth' " adjust shiftwidth and expandtab based on project
Plug 'bling/vim-bufferline' " display buffers in cmdline
Plug 'qpkorr/vim-bufkill' " del/close buffer without changing layout
" {{{
nnoremap :bd<CR> :BD<cr>
" }}}
Plug 'xolox/vim-misc' " misc addons
" Completion ==================================================================
Plug 'xolox/vim-easytags' " autogenerate ctags
Plug 'SirVer/ultisnips' " snippet manager: http://vimcasts.org/episodes/meet-ultisnips/
" {{{
nnoremap <leader>se :UltiSnipsEdit<CR>
let g:UltiSnipsSnippetsDir = '~/.nvim/UltiSnips'
let g:UltiSnipsEditSplit = 'horizontal'
let g:UltiSnipsListSnippets = '<nop>'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:ulti_expand_or_jump_res = 0
" }}}
Plug 'honza/vim-snippets' " some predefined snippets
" File/Text Navigation ========================================================
Plug 'scrooloose/nerdtree' " file drawer
" {{{
let g:NERDTreeMinimalUI = 1
let g:NERDTreeHijackNetrw = 0
let g:NERDTreeWinSize = 31
let g:NERDTreeChDirMode = 2
let g:NERDTreeAutoDeleteBuffer = 1
let g:NERDTreeShowBookmarks = 1
let g:NERDTreeCascadeOpenSingleChildDir = 1
map <C-n> :NERDTreeToggle<CR>
map <F1> :call NERDTreeToggleAndFind()<cr>
function! NERDTreeToggleAndFind()
if (exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1)
execute ':NERDTreeClose'
else
execute ':NERDTreeFind'
endif
endfunction
" close vim fully if the only other open buffer is a NT
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" }}}
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim' " fuzzy file finder
" {{{
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nnoremap <silent> <leader><space> :Files<CR>
nnoremap <silent> <leader>a :Buffers<CR>
nnoremap <silent> <leader>A :Windows<CR>
nnoremap <silent> <leader>; :BLines<CR>
nnoremap <silent> <leader>o :BTags<CR>
nnoremap <silent> <leader>O :Tags<CR>
nnoremap <silent> <leader>? :History<CR>
nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
nnoremap <silent> <leader>. :AgIn
nnoremap <silent> K :call SearchWordWithAg()<CR>
vnoremap <silent> K :call SearchVisualSelectionWithAg()<CR>
nnoremap <silent> <leader>gl :Commits<CR>
nnoremap <silent> <leader>ga :BCommits<CR>
nnoremap <silent> <leader>ft :Filetypes<CR>
imap <C-x><C-f> <plug>(fzf-complete-file-ag)
imap <C-x><C-l> <plug>(fzf-complete-line)
function! SearchWordWithAg()
execute 'Ag' expand('<cword>')
endfunction
function! SearchVisualSelectionWithAg() range
let old_reg = getreg('"')
let old_regtype = getregtype('"')
let old_clipboard = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', old_reg, old_regtype)
let &clipboard = old_clipboard
execute 'Ag' selection
endfunction
function! SearchWithAgInDirectory(...)
call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout))
endfunction
command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory(<f-args>)
" }}}
Plug 'rhysd/clever-f.vim' " better handling of 'f'
" {{{
let g:clever_f_across_no_line = 1
" }}}
" Text Manipulation ===========================================================
Plug 'tpope/vim-surround' " quoting/parenthesizing (ds, cs, ys)
Plug 'tpope/vim-commentary' " gc{motion} to add comments
Plug 'tpope/vim-repeat' " repeat motions (.) improved
Plug 'Raimondi/delimitMate' " intelligent insert mode autoclose
" {{{
let delimitMate_expand_cr = 2
let delimitMate_expand_space = 1 " {|} => { | }
" }}}
Plug 'AndrewRadev/sideways.vim' " shift items with SPC+> and SPC+<
" {{{
nnoremap <Leader>< :SidewaysLeft<CR>
nnoremap <Leader>> :SidewaysRight<CR>
" }}}
Plug 'tpope/vim-speeddating' " use CTRL+A CTRL+A to increment dates etc
" Text Objects ================================================================
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-indent'
Plug 'kana/vim-textobj-function'
Plug 'kana/vim-textobj-datetime'
Plug 'wellle/targets.vim'
" Languages ===================================================================
Plug 'mattn/emmet-vim' " clever autoexpand
" {{{
let g:user_emmet_expandabbr_key = '<c-e>'
" }}}
Plug 'sheerun/vim-polyglot' " library for language syntaxes and more
" {{{
" PHP.vim, see: https://github.com/StanAngeloff/php.vim/issues/37
" Put at the very end of your .vimrc file.
let php_var_selector_is_identifier = 0
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
hi! phpFunctions ctermfg=172 ctermbg=NONE cterm=NONE
hi! phpVarSelector ctermfg=69 ctermbg=NONE cterm=NONE
hi! phpMemberSelector ctermfg=136 ctermbg=NONE cterm=NONE
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
" }}}
Plug 'othree/javascript-libraries-syntax.vim'
" {{{
let g:used_javascript_libs = 'jquery'
" }}}
Plug 'ap/vim-css-color' " highlight css colors
Plug 'tpope/vim-jdaddy' " json support
Plug 'qbbr/vim-twig'
Plug 'ekalinin/Dockerfile.vim'
" Git =========================================================================
Plug 'tpope/vim-fugitive' " add git commands as :G<command>
" {{{
" Fix broken syntax highlight in gitcommit files
" (https://github.com/tpope/vim-git/issues/12)
let g:fugitive_git_executable = 'LANG=en_US.UTF-8 git'
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
nnoremap <silent> <leader>gE :Gedit<space>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gR :Gread<space>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>gW :Gwrite!<CR>
nnoremap <silent> <leader>gq :Gwq<CR>
nnoremap <silent> <leader>gQ :Gwq!<CR>
function! ReviewLastCommit()
if exists('b:git_dir')
Gtabedit HEAD^{}
nnoremap <buffer> <silent> q :<C-U>bdelete<CR>
else
echo 'No git a git repository:' expand('%:p')
endif
endfunction
nnoremap <silent> <leader>g` :call ReviewLastCommit()<CR>
augroup fugitiveSettings
autocmd!
autocmd FileType gitcommit setlocal nolist
autocmd BufReadPost fugitive://* setlocal bufhidden=delete
augroup END
" }}}
Plug 'airblade/vim-gitgutter' " display git changes in gutter
" {{{
let g:gitgutter_map_keys = 0
let g:gitgutter_max_signs = 200
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1
let g:gitgutter_sign_removed = '–'
let g:gitgutter_diff_args = '--ignore-space-at-eol'
nmap <silent> ]h :GitGutterNextHunk<CR>
nmap <silent> [h :GitGutterPrevHunk<CR>
nnoremap <silent> <Leader>gu :GitGutterRevertHunk<CR>
nnoremap <silent> <Leader>gp :GitGutterPreviewHunk<CR><c-w>j
nnoremap cog :GitGutterToggle<CR>
nnoremap <Leader>gt :GitGutterAll<CR>
" }}}
Plug 'jreybert/vimagit' " emacs magit in vim
" Utility =====================================================================
Plug 'tpope/vim-eunuch' " add :Remove :Rename et al
Plug 'tpope/vim-characterize'
Plug 'tpope/vim-unimpaired'
" {{{
nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
" }}}
Plug 'tyru/open-browser.vim'
" {{{
let g:netrw_nogx = 1
vmap gx <Plug>(openbrowser-smart-search)
nmap gx <Plug>(openbrowser-smart-search)
" }}}
" Misc
" ====================================================================
Plug 'itchyny/calendar.vim', { 'on': 'Calendar' }
" {{{
let g:calendar_date_month_name = 1
" }}}
call plug#end() " Plugins initialization finished {{{
" }}}
" vim: set ft=vim