-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvimrc.2021
289 lines (246 loc) · 10.1 KB
/
vimrc.2021
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-plug
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/gv.vim'
" Coc Requirements:
" 1. node: brew install node
" 2. :CocInstall coc-lists coc-json
" 3. :CocInstall coc-go
" 4. gem install solargraph, :CocInstall coc-solargraph
" 5. :CocInstall coc-snippets
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'honza/vim-snippets'
Plug 'fatih/vim-go'
Plug 'christoomey/vim-tmux-navigator'
Plug 'altercation/vim-colors-solarized'
Plug 'preservim/nerdtree'
Plug 'preservim/tagbar'
Plug 'vim-scripts/tComment'
Plug 'easymotion/vim-easymotion'
Plug 'mhinz/vim-signify'
Plug 'andymass/vim-matchup'
Plug 'hecal3/vim-leader-guide'
Plug 'liuchengxu/vista.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'mg979/vim-visual-multi'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'edkolev/tmuxline.vim'
Plug 'voldikss/vim-floaterm'
" Plug 'plasticboy/vim-markdown'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-bundler'
" Plug 'tpope/vim-markdown'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
" Plug 'tpope/vim-vividchalk'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype plugin indent on " Load plugins according to detected filetype.
syntax on " Enable syntax highlighting.
set autoindent " Indent according to previous line.
scriptencoding utf-8
set encoding=utf-8 " Set default encoding
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
set ttyfast " Faster redrawing
set belloff=all
set novisualbell
set noerrorbells
" set paste " Do not format when pasting from clipboard
set hidden " Allow buffer switching without saving
set autoread " Automatically read a file changed outside of vim
" set autowrite " Automatically write a file when leaving a modified buffer
set nobackup
set noswapfile
set nowritebackup
set smarttab
set expandtab " Use spaces instead of tabs.
set tabstop=2 " Tab key indents by 2 spaces.
set softtabstop=2 " Let backspace delete indent.
set shiftwidth=2 " >> indents by 2 spaces.
set backspace=indent,eol,start " Make backspace work as you would expect.
set laststatus=2 " Always show statusline.
set display+=lastline " Show as much as possible of the last line.
set number
set ruler
set colorcolumn=80
set showmode " Show current mode in command-line.
set showcmd " Show already typed keys when more are expected.
set showmatch " Show matching brackets/parentthesis
set matchtime=5 " Show matching time
set incsearch " Highlight while searching with / or ?.
set hlsearch " Keep matches highlighted.
set ignorecase " Case insensitive search
set smartcase " ... but case sensitive when uc present
set splitbelow " Open new windows below the current window.
set splitright " Open new windows right of the current window.
set diffopt+=vertical " Show diff in vertical windows
set wildmenu " Show list instead of just completing
set wildignorecase
set wildmode=list:longest,full
match Error /\t/ " Show TAB and trailing space in red
2match Error / /
set list " Show non-printable characters.
set listchars=tab:»·,trail:·,nbsp:·,extends:↷,precedes:↶
" From https://github.com/neoclide/coc.nvim#example-vim-configuration
set updatetime=300 " Default is 4000 ms = 4 s
set shortmess+=c " Don't pass messages to |ins-completion-menu|.
set timeoutlen=500 " By default timeoutlen is 1000 ms
if !has('nvim') && &ttimeoutlen == -1
set ttimeout " time out for key codes
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
endif
" runtime! macros/matchit.vim " No need matchit if vim-matchup enabled
au FileType c,cpp,go setl noexpandtab nolist ts=4 sw=4 sts=4
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" map
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap j gj
nnoremap k gk
let mapleader = " "
nnoremap <leader><leader> <c-^>
nnoremap <silent> <leader>w <C-w>v<C-w>l
nnoremap <silent> <leader>d :noh<CR>
nnoremap <silent> <leader>q :q<CR>
nnoremap <silent> <leader>f :Files<CR>
nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>l :Lines<CR>
nnoremap <silent> <leader>h :History<CR>
nnoremap <silent> <leader>v :Vista<CR>
nnoremap <leader>a :Ag<Space>
nnoremap <leader>r :Rg<Space>
function! MyToggleNERDTreeFind()
if g:NERDTree.IsOpen()
NERDTreeClose
else
NERDTreeFind
endif
endfunction
noremap <silent> <leader>t :call MyToggleNERDTreeFind()<CR>
" vim-leader-guide
let g:lmap = {}
call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
let g:lmap.g = { 'name' : 'Git [+]' }
nnoremap <silent> <leader>gc :Commits<CR>
nnoremap <silent> <leader>gv :GV<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gd :Gdiffsplit<CR>
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>ga :Git add %<CR>
nnoremap <silent> <leader>gl :FloatermNew --autoclose=2 lazygit<CR>
nnoremap <silent> <leader>n :FloatermNew --autoclose=2<CR>
if has('nvim')
nnoremap <silent> <leader>o :FloatermNew --autoclose=2 ranger<CR>
else
nnoremap <silent> <leader>o :FloatermNew --autoclose=2 lf<CR>
endif
" vim-easy-align
vmap <Enter> <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" vim-easymotion
let g:EasyMotion_do_mapping = 0 " Disable default mappings
let g:EasyMotion_smartcase = 1 " Turn on case-insensitive feature
map f <Plug>(easymotion-f)
nmap f <Plug>(easymotion-overwin-f)
" overwin not implemented for F, t, T
map F <Plug>(easymotion-F)
map t <Plug>(easymotion-t)
map T <Plug>(easymotion-T)
map <leader>s <Plug>(easymotion-sn)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" coc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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
" imap <C-l> <Plug>(coc-snippets-expand)
imap <C-j> <Plug>(coc-snippets-expand-jump)
let g:coc_snippet_next = '<tab>'
let g:coc_snippet_prev = '<c-k>'
" 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>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
let g:lmap.c = { 'name' : 'Coc [+]' }
xmap <leader>ca <Plug>(coc-codeaction-selected)
nnoremap <silent> <leader>ca <Plug>(coc-codeaction-selected)
nnoremap <silent> <leader>cb :CocList buffers<CR>
nnoremap <silent> <leader>cd :CocList diagnostics<CR>
nnoremap <silent> <leader>ce :CocCommand explorer<CR>
nnoremap <silent> <leader>cf :CocList files<CR>
nnoremap <silent> <leader>cs :CocList snippets<CR>
nnoremap <leader>cg :CocList grep<Space>
nnoremap <silent> <leader>cr <Plug>(coc-rename)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" gui
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('gui_running')
" disable blinking for all modes (the "a" specifies all modes, and
" the 0 value for blinkon disables blinking):
set guicursor+=a:blinkon0
set guifont=Monaco:h14
set guioptions-=r " Hide the right scrollbar
set guioptions-=L " Hide the left scrollbar
set guioptions-=T
set guioptions-=e
" If you want the window as big as possible, you can set these options to
" very large values: https://github.com/b4winckler/macvim/wiki/FAQ
set columns=1024
set lines=1024
set background=light
colorscheme solarized
highlight SignifySignAdd gui=bold guibg=NONE guifg=#719e07
highlight SignifySignDelete gui=bold guibg=NONE guifg=#dc322f
highlight SignifySignChange gui=bold guibg=NONE guifg=#b58900
else
set background=dark
colorscheme solarized
highlight SignifySignAdd cterm=bold ctermbg=NONE ctermfg=119
highlight SignifySignDelete cterm=bold ctermbg=NONE ctermfg=167
highlight SignifySignChange cterm=bold ctermbg=NONE ctermfg=227
endif
highlight clear SignColumn " SignColumn should match background
" vim-matchup
hi MatchWord ctermfg=red guifg=red cterm=underline gui=underline