-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
591 lines (471 loc) · 15.2 KB
/
init.vim
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
" WARNING. FILE AUTOMATICALLY GENERATED BY FILE vim.org. DO NOT EDIT.
" TO REGENERATE. Do `emacs ~/.vim/vim.org` and `C-c C-v t` to tangle vimrc
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=$HOME/.config/nvim/dein/repos/github.com/Shougo/dein.vim
" Required:
if dein#load_state($HOME.'/.config/nvim/')
call dein#begin($HOME.'/.config/nvim/')
" Let dein manage dein
" Required:
call dein#add($HOME.'/.config/nvim/dein/repos/github.com/Shougo/dein.vim')
" Language server support
call dein#add('autozimu/LanguageClient-neovim', {
\ 'rev': 'next',
\ 'build': './install.sh',
\ })
call dein#add('Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' })
" Add or remove your plugins here:
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('ledger/vim-ledger')
" Snippets
call dein#add('SirVer/ultisnips')
call dein#add('honza/vim-snippets') " This are the actual snippets
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsListSnippets="<c-tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" Replacecment for Grep
call dein#add('numkil/ag.nvim')
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" ReST documentation plugin
call dein#add('Rykka/riv.vim')
" Git plugins
call dein#add('tpope/vim-fugitive.git')
call dein#add('int3/vim-extradite') " Extend fugitive capabilities
" Bars, panels and files
call dein#add('Shougo/unite.vim')
" Text manipulation
call dein#add('vim-scripts/Align')
call dein#add('vim-scripts/Gundo')
call dein#add('tpope/vim-commentary')
call dein#add('godlygeek/tabular')
call dein#add('tpope/vim-surround.git')
call dein#add('vim-scripts/The-NERD-tree.git')
call dein#add('altercation/vim-colors-solarized.git')
call dein#add('scrooloose/syntastic.git')
call dein#add('techlivezheng/vim-plugin-minibufexpl')
call dein#add('Shougo/vimproc',{
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ })
call dein#add('jgdavey/tslime.vim') "Send snippets to tmux
call dein#add('derekwyatt/vim-scala')
" Jenkinsfile
call dein#add('martinda/Jenkinsfile-vim-syntax')
" Haskell
call dein#add('raichoo/haskell-vim')
call dein#add('begriffs/vim-haskellConceal')
call dein#add('eagletmt/ghcmod-vim')
call dein#add('eagletmt/neco-ghc')
call dein#add('Twinside/vim-hoogle')
call dein#add('chrisbra/NrrwRgn')
" Python development
call dein#add('klen/python-mode')
call dein#add('davidhalter/jedi-vim')
" You can specify revision/branch/tag.
call dein#add('Shougo/vimshell', { 'rev': '3787e5' })
" Syntax Highlight
" Pig
call dein#add('motus/pig.vim')
" Avro
call dein#add('gurpreetatwal/vim-avro')
" Required:
call dein#end()
call dein#save_state()
endif
" Start searching in the root project
let g:ag_working_path_mode="ra"
" bind K to grep word under cursor
nnoremap K :Ag <C-R><C-W><CR>:cw<CR>
set completeopt=menuone,menu,longest
set wildignore+=*\\tmp\\*,*.swp,*.swo,*.zip,.git,.cabal-sandbox
set wildmode=longest,list,full
set wildmenu
set completeopt+=longest
" Remaps
:nnoremap <F9> :NERDTree<cr>
:nnoremap <F8> :NERDTreeClose<cr>
:tnoremap <Esc> <C-\><C-n>
".vimrc
map <A-f> :call JsBeautify()<cr>
" or
autocmd FileType javascript noremap <buffer> <A-f> :call JsBeautify()<cr>
" for json
autocmd FileType json noremap <buffer> <A-f> :call JsonBeautify()<cr>
" for jsx
autocmd FileType jsx noremap <buffer> <A-f> :call JsxBeautify()<cr>
" for html
autocmd FileType html noremap <buffer> <A-f> :call HtmlBeautify()<cr>
" for css or scss
autocmd FileType css noremap <buffer> <A-f> :call CSSBeautify()<cr>
let g:syntastic_html_tidy_ignore_errors=["<ion-", "discarding unexpected </ion-", " proprietary attribute \"ng-"]
" Unite menus
let g:unite_source_menu_menus = {}
" menu prefix key (for all Unite menus) {{{
nmap <LocalLeader> [menu]
" }}}
" menus menu
nnoremap <silent>[menu]u :Unite -silent -winheight=20 menu<CR>
" file searching menu {{{
let g:unite_source_menu_menus.grep = {
\ 'description' : ' search files
\ ⌘ [space]a',
\}
let g:unite_source_menu_menus.grep.command_candidates = [
\['▷ grep (ag → ack → grep) ⌘ ,a',
\'Unite -no-quit grep'],
\['▷ find',
\'Unite find'],
\['▷ locate',
\'Unite -start-insert locate'],
\['▷ vimgrep (very slow)',
\'Unite vimgrep'],
\]
nnoremap <silent>[menu]a :Unite -silent menu:grep<CR>
" Haskell menu {{{
let g:unite_source_menu_menus.haskell = {
\ 'description' : ' haskell commands
\ ⌘ [space]h',
\}
let g:unite_source_menu_menus.haskell.command_candidates = [
\['▷ create tags ⌘ ,_ct',
\'[menu]ct'],
\]
" }}}
nnoremap <silent>[menu]h :Unite -silent menu:haskell<CR>
" |_ct| create |tags| file
" |_si| show info for id under cursor
" |_t| show type for id under cursor
" |_T| insert type declaration for id under cursor
nnoremap <leader>el :ElmEvalLine<CR>
vnoremap <leader>es :<C-u>ElmEvalSelection<CR>
nnoremap <leader>em :ElmMakeCurrentFile<CR>
let g:jedi#force_py_version = 3
let g:LanguageClient_serverCommands = {
\ 'haskell': ['hie', '--lsp'],
\ }
filetype plugin indent on " Required!
" Ctr-p plugin
map <silent> <Leader>t :CtrlP()<CR>
noremap <leader>b<space> :CtrlPBuffer<cr>
let g:ctrlp_custom_ignore = '\v[\/]dist$'
vmap <C-c><C-c> <Plug>SendSelectionToTmux
nmap <C-c><C-c> <Plug>NormalModeSendToTmux
nmap <C-c>r <Plug>SetTmuxVars
" Python development
" Python-mode
" Activate rope
" Keys:
" K Show python docs
" <Ctrl-Space> Rope autocomplete
" <Ctrl-c>g Rope goto definition
" <Ctrl-c>d Rope show documentation
" <Ctrl-c>f Rope find occurrences
" <Leader>b Set, unset breakpoint (g:pymode_breakpoint enabled)
" [[ Jump on previous class or function (normal, visual, operator modes)
" ]] Jump on next class or function (normal, visual, operator modes)
" [M Jump on previous class or method (normal, visual, operator modes)
" ]M Jump on next class or method (normal, visual, operator modes)
let g:pymode_rope = 0
let g:pymode_options_max_line_length=120
autocmd FileType python set colorcolumn=120
" Documentation
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'
"Linting
let g:pymode_lint = 1
let g:pymode_lint_checker = "pyflakes,pep8"
" Auto check on save
let g:pymode_lint_write = 1
" Support virtualenv
let g:pymode_virtualenv = 1
" Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
" syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
" Don't autofold code
let g:pymode_folding = 0
set textwidth=80
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
" Automatically change to current directory
set autochdir
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set ttyfast
set ruler
set autoindent
" Numbering
if v:version > 702
set relativenumber
endif
set number
set pastetoggle=<F2>
" Syntastic configuraiton
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list=1
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = ' -std=c++11'
" I want searching to follow regex rules
nnoremap / /\v
vnoremap / /\v
set incsearch
set showmatch
set hlsearch
" Colors
set t_Co=16 " Necesary for terminator
set background=dark
colorscheme solarized
" Folding
set foldmethod=indent
set foldlevel=99
" Window movement
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Don't use arrows
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" Change mapleader to an easier to reach key
let mapleader = ","
let maplocalleader = "_"
" Turn on the WiLd menu
set wildmenu
" Tab-complete files up to longest unambiguous prefix
set wildmode=list:longest,full
" Height of the command bar
set cmdheight=1
" Task lists
map <leader>td <Plug>TaskList
" Gundo
map <leader>g :GundoToggle<CR>
" Syntaxing
syntax on " syntax highlighing
" Deal with tabs
set expandtab
set list
set listchars=tab:→\
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Different filesyntax
au BufNewFile,BufRead *.pig set filetype=pig syntax=pig
au BufRead,BufNewFile *.nw set filetype=noweb
au BufRead,BufNewFile *.nw set cindent
au BufRead,BufNewFile *.asciidoc set spell tw=80
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
" " Alignment {{{
" Stop Align plugin from forcing its mappings on us
let g:loaded_AlignMapsPlugin=1
" Align on equal signs
map <Leader>a= :Align =<CR>
" Align on commas
map <Leader>a, :Align ,<CR>
" Align on pipes
map <Leader>a<bar> :Align <bar><CR>
" Prompt for align character
map <leader>ap :Align
" Enable some tabular presets for Haskell
let g:haskell_tabular = 1
" }}}
" Slime {{{
vmap <silent> <Leader>rs <Plug>SendSelectionToTmux
nmap <silent> <Leader>rs <Plug>NormalModeSendToTmux
nmap <silent> <Leader>rv <Plug>SetTmuxVars
" }}}
" Haskell {{{
let g:haddock_browser="/usr/bin/firefox"
set iskeyword=a-z,A-Z,_,.,39 " Configuration for hoshasktags
set tags=tags;/,codex.tags;/
let g:tagbar_type_haskell = {
\ 'ctagsbin' : 'hasktags',
\ 'ctagsargs' : '-x -c -o-',
\ 'kinds' : [
\ 'm:modules:0:1',
\ 'd:data: 0:1',
\ 'd_gadt: data gadt:0:1',
\ 't:type names:0:1',
\ 'nt:new types:0:1',
\ 'c:classes:0:1',
\ 'cons:constructors:1:1',
\ 'c_gadt:constructor gadt:1:1',
\ 'c_a:constructor accessors:1:1',
\ 'ft:function types:1:1',
\ 'fi:function implementations:0:1',
\ 'o:others:0:1'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'm' : 'module',
\ 'c' : 'class',
\ 'd' : 'data',
\ 't' : 'type'
\ },
\ 'scope2kind' : {
\ 'module' : 'm',
\ 'class' : 'c',
\ 'data' : 'd',
\ 'type' : 't'
\ }
\ }
" Generate haskell tags with codex and hscope
map <leader>tg :!codex update<CR>:call system("git hscope")<CR><CR>:call LoadHscope()<CR>
map <leader>tt :TagbarToggle<CR>
set csprg=hscope
set csto=1 " search codex tags first
set cst
set csverb
nnoremap <silent> <C-\> :cs find c <C-R>=expand("<cword>")<CR><CR>
" Automatically make cscope connections
function! LoadHscope()
let db = findfile("hscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/hscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
endif
endfunction
au BufEnter /*.hs call LoadHscope()
" }}}
" Haskell Interrogation {{{
set completeopt+=longest
" Use buffer words as default tab completion
let g:SuperTabDefaultCompletionType = '<c-x><c-p>'
" But provide (neco-ghc) omnicompletion
if has("gui_running")
imap <c-space> <c-r>=SuperTabAlternateCompletion("\<lt>c-x>\<lt>c-o>")<cr>
else " no gui
if has("unix")
inoremap <Nul> <c-r>=SuperTabAlternateCompletion("\<lt>c-x>\<lt>c-o>")<cr>
endif
endif
let g:haskellmode_completion_ghc = 1
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" Show types in completion suggestions
let g:necoghc_enable_detailed_browse = 1
" Type of expression under cursor
nmap <silent> <leader>ht :GhcModType<CR>
" Insert type of expression under cursor
nmap <silent> <leader>hT :GhcModTypeInsert<CR>
" GHC errors and warnings
nmap <silent> <leader>hc :SyntasticCheck ghc_mod<CR>
" Haskell Lint
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['haskell'] }
nmap <silent> <leader>hl :SyntasticCheck hlint<CR>
" Hoogle the word under the cursor
nnoremap <silent> <leader>hh :Hoogle<CR>
" Hoogle and prompt for input
nnoremap <leader>hH :Hoogle
" Hoogle for detailed documentation (e.g. "Functor")
nnoremap <silent> <leader>hi :HoogleInfo<CR>
" Hoogle for detailed documentation and prompt for input
nnoremap <leader>hI :HoogleInfo
" Hoogle, close the Hoogle window
nnoremap <silent> <leader>hz :HoogleClose<CR>
" }}}
" Conversion {{{
function! Pointfree()
call setline('.', split(system('pointfree '.shellescape(join(getline(a:firstline, a:lastline), "\n"))), "\n"))
endfunction
vnoremap <silent> <leader>h. :call Pointfree()<CR>
function! Pointful()
call setline('.', split(system('pointful '.shellescape(join(getline(a:firstline, a:lastline), "\n"))), "\n"))
endfunction
vnoremap <silent> <leader>h> :call Pointful()<CR>
" }}}
" Latex
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" Pyflakes
let g:pyflakes_use_quickfix = 0
" Pep 8
let g:pep8_map='<leader>8'
" Git
set statusline=%{fugitive#statusline()}
" Tab completion
au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
set completeopt=menuone,longest,preview
" File NERD
map <leader>n :NERDTreeToggle<CR>
" Refactoring
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>
" Searching
nmap <leader>a <Esc>:Ack!
" Macros
" Aucomment this line and create a copy below
autocmd FileType c,cpp,java,scala let @c='yypk^i// '
autocmd FileType sh,ruby,python let @c='yypk^i# '
autocmd FileType conf,fstab let @c='yypk^i# '
autocmd FileType tex let @c='yypk^i% '
autocmd FileType mail let @c='yypk^i> '
autocmd FileType vim let @c='yypk^i" '
" Unite menus
let g:unite_source_menu_menus = {}
" menu prefix key (for all Unite menus) {{{
nnoremap [menu] <Nop>
nmap <LocalLeader> [menu]
" }}}
" menus menu
nnoremap <silent>[menu]u :Unite -silent -winheight=20 menu<CR>
" file searching menu {{{
let g:unite_source_menu_menus.grep = {
\ 'description' : ' search files
\ ⌘ [space]a',
\}
let g:unite_source_menu_menus.grep.command_candidates = [
\['▷ grep (ag → ack → grep) ⌘ ,a',
\'Unite -no-quit grep'],
\['▷ find',
\'Unite find'],
\['▷ locate',
\'Unite -start-insert locate'],
\['▷ vimgrep (very slow)',
\'Unite vimgrep'],
\]
nnoremap <silent>[menu]a :Unite -silent menu:grep<CR>
" Haskell menu {{{
let g:unite_source_menu_menus.haskell = {
\ 'description' : ' haskell commands
\ ⌘ [space]h',
\}
let g:unite_source_menu_menus.haskell.command_candidates = [
\['▷ create tags ⌘ ,_ct',
\'[menu]ct'],
\]
" }}}
nnoremap <silent>[menu]h :Unite -silent menu:haskell<CR>
" |_ct| create |tags| file
" |_si| show info for id under cursor
" |_t| show type for id under cursor
" |_T| insert type declaration for id under cursor
" Include local configuration
if filereadable(expand("~/.vim.local"))
so ~/.vim.local
endif