-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
executable file
·749 lines (595 loc) · 20.8 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
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
call plug#begin("~/.vim/bundle")
Plug 'altercation/vim-colors-solarized'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-abolish'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-endwise'
Plug 'vim-scripts/IndexedSearch'
Plug 'scrooloose/nerdtree'
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate'
Plug 'godlygeek/tabular'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/taglist.vim'
Plug 'kana/vim-textobj-user'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-surround'
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-unimpaired'
Plug 'tommcdo/vim-exchange'
Plug 'tpope/vim-dispatch'
Plug 'mileszs/ack.vim'
Plug 'rking/ag.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-bundler'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
Plug 'vim-scripts/actionscript.vim--Leider'
Plug 'tpope/vim-markdown'
Plug 'adimit/prolog.vim'
Plug 'rafaelfranca/rtf_pygmentize'
Plug 'vesan/scss-syntax.vim'
Plug 'timcharper/textile.vim'
Plug 'kchmck/vim-coffee-script'
Plug 'tpope/vim-cucumber'
Plug 'elixir-lang/vim-elixir'
Plug 'tpope/vim-rails'
Plug 'ecomba/vim-ruby-refactoring'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'vim-scripts/VimClojure'
Plug 'derekwyatt/vim-scala'
Plug 'bleything/vim-slidedown'
Plug 'skalnik/vim-vroom'
Plug 'mustache/vim-mustache-handlebars'
Plug 'tpope/vim-jdaddy'
Plug 'wting/rust.vim'
Plug 'slim-template/vim-slim'
Plug 'lambdatoast/elm.vim'
Plug 'tpope/vim-eunuch'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'vimwiki/vimwiki'
Plug 'tpope/vim-repeat'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
" TypeScript
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
" Vue
Plug 'posva/vim-vue'
" Plug 'Quramy/tsuquyomi-vue'
autocmd BufNewFile,BufRead *.vue set filetype=vue
" ReasonML
Plug 'reasonml-editor/vim-reason-plus'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ 'for': 'reason',
\ }
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins', 'for': 'reason' }
else
Plug 'Shougo/deoplete.nvim', { 'for': 'reason' }
Plug 'roxma/nvim-yarp', { 'for': 'reason' }
Plug 'roxma/vim-hug-neovim-rpc', { 'for': 'reason' }
endif
let g:deoplete#enable_at_startup = 1
let g:LanguageClient_serverCommands = {
\ 'reason': ['ocaml-language-server', '--stdio'],
\ 'ocaml': ['ocaml-language-server', '--stdio'],
\ }
call plug#end()
filetype off
let &runtimepath.=',~/.vim/bundle/ale'
filetype plugin indent on
set omnifunc=syntaxcomplete#Complete
let mapleader = ","
" tsuquyomi
" autocmd FileType typescript nmap <buffer> <Leader>i : <C-u>echo tsuquyomi#hint()<CR>
" let g:tsuquyomi_disable_quickfix = 1
" vim-json
let g:vim_json_syntax_conceal = 0
" Don't load PeepOpen
let g:peepopen_loaded = 1
nmap <leader>t :GFiles<CR>
" nmap <leader>t :Files<CR>
" ctrl-p config
" let g:ctrlp_map = '<leader>t'
let g:ctrlp_match_window_bottom = 0
let g:ctrlp_match_window_reversed = 0
let g:ctrlp_max_height = 20
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](tmp|node_modules)$',
\ 'file': '\v\.(exe|so|dll)$'
\ }
if executable('rg')
let g:ctrlp_user_command = 'rg --files %s'
let g:ctrlp_use_caching = 0
endif
" To get rid of complaining makegreen
if !hasmapto('<Plug>MakeGreen')
map <unique> <silent> <Leader>ö <Plug>MakeGreen
endif
" Rock the simple shell instead of ZSH
set shell=/bin/sh
" silent! call pathogen#runtime_append_all_bundles()
" silent! call pathogen#helptags()
runtime macros/matchit.vim " Load the matchit plugin.
set nobackup " do not keep a backup file, use versions instead
" set noswapfile " ... or don't keep swap files at all
set noundofile
set nowritebackup " And again.
set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
set history=50 " keep 50 lines of command line history
set showcmd " display incomplete commands
set showmode " display the mode you're in.
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set cursorline " Highlight current line.
set incsearch " Highlight matches as you type.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set visualbell " No beeping.
set expandtab " Use spaces instead of tabs
set tabstop=2 " Global tab width.
set softtabstop=2 " And again, related.
set shiftwidth=2 " And again, related.
set laststatus=2 " Show the status line all the time
" Useful status information at bottom of screen
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
set splitbelow
set gdefault " assume the /g flag on :s substitutions to replace all matches in a line
set nofoldenable " disable folding
set autoread " if file has been changed outside of vim, reload it
" set winwidth=84
" We have to have a winheight bigger than we want to set winminheight. But if
" we set winheight to be huge before winminheight, the winminheight set will
" fail.
set winheight=10
set winminheight=10
set winheight=999
set wildignore+=*.o,*.png,*.PNG,*.JPG,*.jpg,*.jpeg,*.JPEG,*.gif,*.pdf,*.jar,*.scssc,coverage/**,tmp/**
set iskeyword+=-
" Shortcut to rapidly toggle `set list`
map <leader>l :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
" Vim 7.4 is really slow with Ruby files unless you set this.
set regexpengine=1
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
set mouse=a
" Native clipboard integration
set clipboard=unnamed
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax enable
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
" Reload vim config automatically after editing it
autocmd bufwritepost .vimrc source $MYVIMRC
autocmd bufwritepost vimrc source $MYVIMRC
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd WinEnter * match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set background=dark
colorscheme solarized
" Other nice ones: ir_black, inkpot, railscasts
" Customizing Vim
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" COMMAND LINE CUSTOMIZATIONS
" Basic emacs keybindings
cnoremap <C-A> <Home>
cnoremap <C-B> <Left>
cnoremap <C-E> <End>
cnoremap <C-F> <Right>
cnoremap <C-N> <Down>
cnoremap <C-P> <Up>
" cnoremap <ESC>b <S-Left>
" cnoremap <ESC>f <S-Right>
" cnoremap <ESC><C-H> <C-W>
" Normal mode - emacs style movements [960425]
nmap <C-A> 0
nmap <C-B> h
nmap <C-E> $
nmap <C-F> l
nmap <ESC>b b
nmap <ESC>f w
imap <c-e> <c-o>$
imap <c-a> <c-o>^
" Split mappings
" map <C-H> <C-W>h<C-W><BAR>
" map <C-L> <C-W>l<C-W><BAR>
" map <C-J> <C-W>j<C-W>_
" map <C-K> <C-W>k<C-W>_
map <C-H> <C-W>h
map <C-L> <C-W>l
map <C-J> <C-W>j
map <C-K> <C-W>k
" Automatic fold settings for specific files. Uncomment to use.
" autocmd FileType ruby set foldmethod=syntax
" autocmd FileType css setlocal foldmethod=indent shiftwidth=2 tabstop=2
autocmd FileType php setlocal shiftwidth=4 softtabstop=4
" For the MakeGreen plugin and Ruby RSpec. Uncomment to use.
" autocmd BufNewFile,BufRead *_spec.rb compiler rspec
command! W w
command! Q q
" ale
" let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ 'javascript': [
\ 'eslint',
\ 'prettier_eslint'
\ ],
\ 'typescript': [
\ 'eslint',
\ 'prettier_eslint'
\ ],
\ 'ruby': [
\ 'standardrb'
\ ]
\}
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\ }
let g:ale_javascript_prettier_use_local_config = 1
" let g:ale_linters = {
" \ 'typescript': [
" \ 'tsserver',
" \ 'typecheck'
" \ ]
" \}
nmap <silent> <leader>k <Plug>(ale_previous_wrap)
nmap <silent> <leader>j <Plug>(ale_next_wrap)
" NERDTree
nmap <leader>d :NERDTreeToggle<cr>
nmap <leader>r :NERDTreeFind<cr>
" vim-vroom
let g:vroom_map_keys = 0
map <Leader>v :VroomRunTestFile<CR>
map <Leader>V :VroomRunNearestTest<CR>
" HTML
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" Emulate TextMate indenting style
nmap <M-Tab> >>
nmap <M-S-Tab> <<
vmap <M-Tab> >gv
vmap <M-S-Tab> <gv
" and Command-Enter functionality
inoremap <D-CR> <C-O>o
" Set SnipMate author
let g:snips_author = "Vesa Vänskä"
let g:snippets_dir = "~/.vim/snippets/"
" Tabular
" TODO Fix the if, for some reason with it the code is not loaded
" if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<cr>
vmap <Leader>a= :Tabularize /=<cr>
nmap <Leader>a: :Tabularize /:\zs<cr>
vmap <Leader>a: :Tabularize /:\zs<cr>
nmap <Leader>a{ :Tabularize /{<cr>
vmap <Leader>a{ :Tabularize /{<cr>
" endif
let Tlist_WinWidth = 30
" Faster way to get to previous file
nmap gb <C-^>
" Shortcuts for per line moving
vmap <D-j> gj
vmap <D-k> gk
vmap <D-4> g$
vmap <D-6> g^
vmap <D-0> g0
nmap <D-j> gj
nmap <D-k> gk
nmap <D-4> g$
nmap <D-6> g^
nmap <D-0> g0
" Text bubbling (moving lines and visual selections)
nmap <C-Up> [e
nmap <C-Down> ]e
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Autocomplete file edit path to current file path
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :e %%
function! StripTrailingWhitespace()
if !&binary && &filetype != 'diff'
normal mz
normal Hmy
%s/\s\+$//e
normal 'yz<CR>
normal `z
endif
endfunction
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
function! OpenChangedFiles()
only
let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')
let filenames = split(status, "\n")
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "sp " . filename
endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
nmap <leader><space> :call StripTrailingWhitespace()<CR>
" Clear the search buffer when hitting return
nnoremap <CR> :nohlsearch<cr>
nmap <silent> ,7 :nohlsearch<cr>
" Sudo
cmap w!! w !sudo tee % >/dev/null
" Ruby
map <leader>c :!ruby -I"test" -I"spec" %<CR>
" Ruby
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd BufNewFile,BufRead *.ru set ft=ruby
autocmd BufNewFile,BufRead *.rabl set ft=ruby
" Rails keycombos
imap <C-l> <Space>=><Space>
" Rspec, needed for MakeGreen plugin
autocmd BufNewFile,BufRead *_spec.rb compiler rspec
" Promote variable to RSpec let
function! PromoteToLet()
normal! dd
" exec '?^\s*it\>'
normal! P
.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
normal ==
endfunction
command! PromoteToLet :call PromoteToLet()
map <leader>p :PromoteToLet<cr>
let g:rails_projections = {
\ "app/uploaders/*_uploader.rb": {
\ "command": "uploader",
\ "template":
\ "class %SUploader < CarrierWave::Uploader::Base\nend",
\ "test": [
\ "spec/models/%s_uploader_spec.rb",
\ "test/unit/%s_uploader_test.rb"
\ ],
\ "keywords": "process version"
\ },
\ "features/support/*.rb": {"command": "support"},
\ "features/support/env.rb": {"command": "support"}}
\ "spec/factories/*_factory.rb": {
\ "command": "factory",
\ "affinity": "model",
\ "related": "app/models/%s.rb",
\ "template": "FactoryGirl.define do\n factory :%s do\n end\nend"
\ },
\ "app/presenters/*_presenter.rb": {
\ "command": "presenter",
\ "affinity": "model",
\ "alternate": ["spec/presenters/%s_presenter_spec.rb", "test/presenters/%s_presenter_test.rb"],
\ "related": "app/models/%s.rb",
\ "template": "class %SPresenter\nend"
\ },
\ "app/authorizers/*_authorizer.rb": {
\ "command": "authorizer",
\ "affinity": "model",
\ "alternate": ["spec/authorizers/%s_authorizer_spec.rb", "test/authorizers/%s_authorizer_test.rb"],
\ "related": "app/models/%s.rb",
\ "template": "class %SAuthorizer < ApplicationAuthorizer\nend"
\ },
\ "config/locales/*fi.yml": { "alternate": "%sen.yml" },
\ "config/locales/*en.yml": { "alternate": "%sfi.yml" }
" Prolog
autocmd BufNewFile,BufRead ~/code/prolog/*.pl set filetype=prolog
" ActionScript
autocmd BufNewFile,BufRead *.as set filetype=actionscript
" Markdown
autocmd BufNewFile,BufRead *.suits set filetype=markdown
" CSS
autocmd FileType css,scss set omnifunc=csscomplete#CompleteCSS
" JavaScript
autocmd BufNewFile,BufRead *.es6 set filetype=javascript
noremap <leader>å :set paste<CR>:put *<CR>:set nopaste<CR>
noremap + :cn<cr>
noremap å :cp<cr>
" Ack
" map <leader>s :Ack <c-r><c-w><cr>
let g:ackprg = 'ag --nogroup --nocolor --column'
map <leader>s :execute "Ack " . expand("<cword>") <cr>
" Search for selected text, forwards or backwards.
" From http://vim.wikia.com/wiki/Search_for_visually_selected_text
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>
" find merge conflict markers
nnoremap <Leader>! /\v^[<=>]{7}( <Bar>$)/<Return>
" visually select the text that was last edited or pasted
nnoremap gV `[v`]
" visually select a search result
nnoremap g/ //e<Return>v??<Return>
" Preserve flags when repeating a substitution
nnoremap & :&&<CR>
xnoremap & :&&<CR>
" Settings for VimClojure
let vimclojure#HighlightBuiltins=1 " Highlight Clojure's builtins
let vimclojure#ParenRainbow=1 " Rainbow parentheses'!
" tmux
" http://snk.tuxfamily.org/log/vim-256color-bce.html
" Disable Background Color Erase (BCE) so that color schemes
" work properly when Vim is used inside tmux and GNU screen.
if &term =~ '256color'
set t_ut=
endif
" Load local configs
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" Format JS files using gq
autocmd FileType javascript set formatprg=prettier\ --stdin
" JS
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" Vimwiki
let g:vimwiki_list = [{'path': '~/Dropbox/Notes',
\ 'syntax': 'markdown', 'ext': '.md'}]
nmap <Leader>+ <Plug>VimwikiNormalizeLink
vmap <Leader>+ <Plug>VimwikiNormalizeLinkVisual
let g:vimwiki_url_maxsave = 0
" Support for mailplane links
function! VimwikiLinkHandler(link)
let link = a:link
if link =~# '^\(mailplane:\|omnifocus:\)'
try
call system('open ' . shellescape(link).' &')
return 1
catch
echo "This can happen for a variety of reasons ..."
return 0
endtry
else
return 0
endif
endfunction
" prettier
let g:prettier#config#trailing_comma = 'es5'
let g:prettier#quickfix_enabled = 0
let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
let g:prettier#config#single_quote = 'false'
let g:prettier#config#bracket_spacing = 'true'
" autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql PrettierAsync
" coc.vim
" command! -nargs=0 Prettier :call CocAction('runCommand', 'prettier.formatFile')
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
" if exists('*complete_info')
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
" else
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" endif
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" rg
" set grepprg=rg\ --vimgrep