-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindings.vim
106 lines (83 loc) · 2.6 KB
/
bindings.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
let mapleader=","
let maplocalleader="\\"
" https://stackoverflow.com/questions/290465/how-to-paste-over-without-overwriting-register
xnoremap p pgvy
" Normalization
nnoremap Y yg_
nnoremap v$ vg_
nnoremap vv ^vg_
" Use ; for : in normal and visual mode, less keystrokes
nnoremap ; :
vnoremap ; :
" New line while not at the end of the current one
inoremap <C-J> <ESC>o
" Reordering lines (vim-unimpaired)
nmap <C-j> ]e==
nmap <C-k> [e==
vmap <C-j> ]egv=gv
vmap <C-k> [egv=gv
" Strip trailing spaces
nnoremap <leader><leader>s :%s/\s\+$//g<CR>
" Windows
nnoremap <space> <C-w>w
nnoremap <leader>x :bd<CR>
" Purge the current buffer, both the file representation on disk and the Vim buffer (https://stackoverflow.com/a/16679182/772874)
nnoremap <leader>xd :call delete(expand('%:p')) \| bdelete!<CR>
nnoremap <leader>x! :bufdo bd<CR>
" Remove highlight
nnoremap <leader>h :noh<CR>
" Quick save
nnoremap <C-s> :w<CR>
inoremap <C-s> <ESC>:w<CR>
" Prev/next in command mode with filtering
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" Rake
nnoremap <leader>rdm :Rake db:migrate<CR>
nnoremap <leader>rdtp :Rake db:test:prepare<CR>
" Puma-dev
nnoremap <leader>pr :!puma-dev -stop<CR><CR>
" Plugins
nnoremap <C-t> :NERDTreeToggle<CR>
" fzf
nnoremap <C-p> :Files<CR>
nnoremap <C-l> :Buffers<CR>
nnoremap <C-y> :History<CR>
nnoremap <Leader>a :Rg<space>
nnoremap <leader>ga :Git a<CR>
nnoremap <leader>gc :Git commit<CR>
nnoremap <leader>gca :Git commit --amend<CR>
nnoremap <leader>gf :Git fresh<CR>
nnoremap <leader>gb :Git blame<CR>
inoremap <silent> <C-h> <C-R>=delimitMate#BS()<CR>
inoremap <silent> <C-l> <C-R>=delimitMate#JumpAny()<CR>
nnoremap - :Switch<cr>
" vim-test
nnoremap <leader>t :TestNearest<CR>
nnoremap <leader>T :TestFile<CR>
nnoremap <leader>l :TestLast<CR>
" coc.nvim
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)
nmap <silent> ge <Plug>(coc-diagnostic-next-error)
" Use K to show documentation in preview window
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" coc.snippets
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction