-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.mappings
132 lines (132 loc) · 5.67 KB
/
.vimrc.mappings
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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Escape insert mode
imap <C-\> <Esc>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent> <C-c> :setlocal <C-R>=&conceallevel ? 'conceallevel=0' : 'conceallevel=2'<CR><CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Quicker window movement
let g:C_Ctrl_j = 'off'
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
if has("nvim")
nnoremap <silent> <leader>q :lua require('nvim-window').pick()<CR>
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Allow moving around between Tmux windows
nnoremap <silent> <C-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <C-j> :TmuxNavigateDown<cr>
nnoremap <silent> <C-k> :TmuxNavigateUp<cr>
nnoremap <silent> <C-l> :TmuxNavigateRight<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Navigate properly when lines are wrapped
nnoremap j gj
nnoremap k gk
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use tab to jump between blocks, because it's easier
nnoremap <tab> %
vnoremap <tab> %
vnoremap > >gv
vnoremap < <gv
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" SYSTEM CLIPBOARD COPY & PASTE SUPPORT
set pastetoggle=<leader>v
"Copy paste to/from clipboard
vnoremap <C-c> "*y
noremap <silent><leader>p :set paste<CR>o<esc>"*]p:set nopaste<cr>"
noremap <silent><leader><S-p> :set paste<CR>O<esc>"*]p:set nopaste<cr>"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" zoom a vim pane, <C-w>= to re-balance
nnoremap <C-w>+ :wincmd _<cr>:wincmd \|<cr>
" nnoremap <leader>= :wincmd =<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" resize panes
nnoremap <silent> <Right> :vertical resize +5<cr>
nnoremap <silent> <Left> :vertical resize -5<cr>
nnoremap <silent> <Up> :resize +5<cr>
nnoremap <silent> <Down> :resize -5<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent> <leader>, :noh<cr> " Stop highlight after searching
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" NerdTree
noremap <silent> <C-n> :NERDTreeToggle<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fugitive mapping
noremap <silent> \g :Git<cr>
noremap <silent> \d :vertical rightbelow Gdiffsplit<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Format mapping
noremap <silent> \f :Neoformat<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <silent> \w :bp<cr>
noremap <silent> \e :bn<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:insert_show()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Zoom / Restore window.
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-\> :ZoomToggle<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("nvim")
nnoremap <silent> <A-t> :split term://bash<CR>
nnoremap <silent> <A-v> :vsplit term://bash<CR>
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Coc mapping
if has("nvim")
nnoremap <silent> [w <Plug>(coc-diagnostic-prev)
nnoremap <silent> ]w <Plug>(coc-diagnostic-next)
nnoremap <silent> [d <Plug>(coc-definition)
nnoremap <silent> ]d <Plug>(coc-declaration)
nnoremap <silent> [i <Plug>(coc-implementation)
nnoremap <silent> ]t <Plug>(coc-type-definition)
nnoremap <silent> [u <Plug>(coc-references-used)
nnoremap <silent> [r <Plug>(coc-references)
nnoremap <silent> ]r <Plug>(coc-rename)
nnoremap <silent> [a <Plug>(coc-codeaction)
nnoremap <silent> [f <Plug>(coc-fix-current)
nnoremap <silent> ]f :<C-u>CocList diagnostics<cr>
nnoremap <silent> [q :<C-u>CocRestart<cr>
nnoremap <silent> ]s :call <SID>show_documentation()<CR>
xnoremap if <Plug>(coc-funcobj-i)
onoremap if <Plug>(coc-funcobj-i)
xnoremap af <Plug>(coc-funcobj-a)
onoremap af <Plug>(coc-funcobj-a)
xnoremap ic <Plug>(coc-classobj-i)
onoremap ic <Plug>(coc-classobj-i)
xnoremap ac <Plug>(coc-classobj-a)
onoremap ac <Plug>(coc-classobj-a)
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""