-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc-neo
110 lines (89 loc) · 3.46 KB
/
vimrc-neo
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
" Enable true color and special cursor for insert mode
if $TERM_PROGRAM == "iTerm.app"
set termguicolors
endif
set guicursor=i:ver1,a:blinkon0
" Use cool popup blending
set pumblend=20
set winblend=10
" Use popup menu for command-line completion
set wildoptions=pum
" See instant feedback when entering commands
set inccommand=nosplit
" Quickly open a Ruby REPL
nnoremap <Leader>e :bel 10split term://pry<CR>
" Run selection in a Ruby REPL
vnoremap <Leader>e y:bel 10split term://pry<CR><C-\><C-n>pi<CR>
" Work around https://github.com/neoclide/coc.nvim/issues/1775
let g:coc_disable_transparent_cursor = 1
" Re-implementation of K with coc.nvim compatibility, taken from docs
function! ShowDocumentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Set up mappings for ALE and coc.nvim
function! s:set_up_coc_bindings()
nmap <buffer> <silent> <Leader>k :CocAction<CR>
vmap <buffer> <silent> <Leader>k <Plug>(coc-codeaction-selected)
nmap <buffer> <silent> <C-p> :call ShowDocumentation()<CR>
nmap <buffer> <silent> <C-]> <Plug>(coc-definition)
nmap <buffer> <silent> <Leader>gtd <Plug>(coc-type-definition)
nmap <buffer> <silent> <Leader>gi <Plug>(coc-implementation)
nmap <buffer> <silent> <Leader>gr <Plug>(coc-references)
nmap <buffer> <silent> <Leader>cr <Plug>(coc-rename)
nmap <buffer> <silent> [d <Plug>(coc-diagnostic-prev)
nmap <buffer> <silent> ]d <Plug>(coc-diagnostic-next)
nmap <buffer> <silent> K :call ShowDocumentation()<CR>
endfunction
autocmd FileType javascript,typescript,typescriptreact,ruby call s:set_up_coc_bindings()
""" Terminal-related config
" Fix meta bindings in terminal
for c in range(0, 25)
let char=nr2char(c + char2nr("a"))
exec "tnoremap <M-" . char . "> <Esc>" . char
let char=nr2char(c + char2nr("A"))
exec "tnoremap <M-" . char . "> <Esc>" . char
endfor
" Bind <C-\><C-[> and <C-\><C-]> to switch tabs in all modes
tnoremap <C-\><C-[> <C-\><C-n>gT
tnoremap <C-\><C-]> <C-\><C-n>gt
nnoremap <C-\><C-[> gT
nnoremap <C-\><C-]> gt
vnoremap <C-\><C-[> gT
vnoremap <C-\><C-]> gt
inoremap <C-\><C-[> <C-o>gT
inoremap <C-\><C-]> <C-o>gt
" Bind <C-\><C-t> to open a new terminal split in normal and terminal modes
tnoremap <C-\><C-t> <C-\><C-n>:split<CR><C-\><C-n>:term<CR>
nnoremap <C-\><C-t> <C-\><C-n>:split<CR><C-\><C-n>:term<CR>
" Bind <C-\><C-p> to paste for convenience
tnoremap <C-\><C-p> <C-\><C-n>p
" Bind <C-\><C-\> to exit terminal
tnoremap <C-\><C-\> <C-\><C-n>
" Bind <M-k> to <C-k> for line editing
tnoremap <M-k> <C-k>
" Increase scrollback
let g:terminal_scrollback_buffer_size=100000
" Allow split navigation directly from terminal
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
" On entering a terminal buffer, automatically enter insert mode unless we're
" scrolled up
function! s:start_insert_if_at_bottom()
if (line('w$') >= line('$'))
startinsert
endif
endfunction
autocmd TermOpen,BufWinEnter,WinEnter term://* call s:start_insert_if_at_bottom()
" When opening a term, disable line numbers; when leaving one, enable them
autocmd TermOpen,BufWinEnter term://* setlocal nonumber
autocmd BufWinLeave term://* setlocal number
" In terminal buffers, make <Enter> automatically jump into insert mode
nnoremap <expr> <Enter> &buftype == 'terminal' ? 'i<CR>' : '<CR>'