-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim.copy
345 lines (268 loc) · 9.05 KB
/
init.vim.copy
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
set nocompatible
filetype off
call plug#begin('~/.config/nvim/plugged')
Plug 'sheerun/vim-polyglot'
Plug 'joshdick/onedark.vim'
Plug 'sonph/onehalf', { 'rtp': 'vim' }
" Git tools
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/gv.vim'
Plug 'sodapopcan/vim-twiggy'
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'PhilRunninger/nerdtree-visual-selection'
Plug 'ryanoasis/vim-devicons'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-emmet', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-eslint'
Plug 'neoclide/coc-tslint', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-tabnine', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-prettier'
Plug 'yaegassy/coc-intelephense', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-rls', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-solargraph', {'do': 'yarn install --frozen-lockfile'}
Plug 'josa42/coc-go', {'do': 'yarn install --frozen-lockfile'}
Plug 'fannheyward/coc-rust-analyzer', {'do': 'yarn install --frozen-lockfile'}
Plug 'iamcco/coc-diagnostic', {'do': 'yarn install --frozen-lockfile'}
Plug 'fannheyward/coc-styled-components', {'do': 'yarn install --frozen-lockfile'}
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'mattn/emmet-vim'
Plug 'preservim/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'SirVer/ultisnips'
Plug 'vim-airline/vim-airline'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-unimpaired'
Plug 'editorconfig/editorconfig-vim'
Plug 'elzr/vim-json'
Plug 'vim-test/vim-test'
Plug 'easymotion/vim-easymotion'
Plug 'itchyny/calendar.vim'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
call plug#end()
let g:coc_global_extensions = [
\ 'coc-emmet',
\ 'coc-css',
\ 'coc-eslint',
\ 'coc-diagnostic',
\ 'coc-styled-components',
\ 'coc-rust-analyzer',
\ 'coc-snippets',
\ 'coc-tsserver'
\ ]
let g:python_host_prog = "/usr/bin/python"
let g:python3_host_prog = "/usr/bin/python3"
syntax on
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Use 256 colors in gui_running mode
if !has('gui_running')
set t_Co=256
endif
set cursorline
colorscheme onedark
set background=dark
set clipboard=unnamedplus
set colorcolumn=120
set number
set nowrap
set smartcase
set hlsearch
set noerrorbells
set softtabstop=2 tabstop=4 shiftwidth=2
set expandtab
set smartindent
set viminfo='20,<1000
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
set foldmethod=syntax
set foldnestmax=10
set nofoldenable
set foldlevel=20
set lazyredraw
set list
set lcs+=space:·
let g:dracula_colorterm = 0
let g:dracula_italic = 0
if has('persistent_undo')
set undofile
silent !mkdir ~/.vim_undo_backup > /dev/null 2>&1
set undodir=~/.vim_undo_backup
endif
map <Space> <Leader>
command! CopyBuffer let @+ = expand('%:p')
nnoremap <c-k> :<c-u>call search('\u')<cr>
nnoremap <S-Up> :m-2<CR>
nnoremap <S-Down> :m+<CR>
inoremap <S-Up> <Esc>:m-2<CR>
inoremap <S-Down> <Esc>:m+<CR>
nnoremap <S-Right> :vertical resize +10<CR>
nnoremap <S-Left> :vertical resize -10<CR>
nnoremap <C-S-Up> :resize +10<CR>
nnoremap <C-S-Down> :resize -10<CR>
map <C-d> 5j
map <C-u> 5k
" nnoremap p "0p
map <F1> <Esc>
imap <F1> <Esc>
function TrimWhiteSpace()
%s/\s*$//
''
endfunction
command Dels :call TrimWhiteSpace()
" NerdTree
function! NERDTreeYankCurrentNode()
let n = g:NERDTreeFileNode.GetSelected()
if n != {}
return n.path.getLastPathComponent(1)
endif
endfunction
command! CopyName let @+ = NERDTreeYankCurrentNode()
" Extensions
au BufRead,BufNewFile *.ftl setfiletype html
" Emmet
let g:user_emmet_settings = {
\ 'typescript' : {
\ 'extends' : 'jsx',
\ },
\}
" Nerdtree
map <silent> <C-m> :NERDTreeFocus<CR>
map <silent> <C-n> :NERDTreeFind<CR>
" COC
" nnoremap <silent> <leader>i :CocAction<cr>
nmap <leader>i <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
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 <leader>qf <Plug>(coc-fix-current)
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Coc List
nnoremap <leader>ccd :CocList diagnostics<CR>
nnoremap <leader>cco :CocList outline<CR>
nmap <leader>e :CocCommand explorer<CR>
nnoremap <silent> h :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
" COC
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" COC eslint
command! -nargs=0 Esfix :call CocAction('runCommand', 'eslint.executeAutofix')
" CocCommand eslint.executeAutofix
" coc go to next eslint problem
nmap ]w <Plug>(coc-diagnostic-next)
nmap [w <Plug>(coc-diagnostic-prev)
" Nerd Comment
" Create default mappings
let g:NERDCreateDefaultMappings = 1
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
let NERDTreeShowHidden=1
" Snippets
let g:UltiSnipsExpandTrigger="<tab>"
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsUsePythonVersion = 3
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
"" GIT
autocmd BufWritePost * GitGutter
nnoremap <leader>god :Gvdiffsplit!<CR>
nnoremap <leader>gos :Git<CR>
nnoremap <leader>gb :Git blame<CR>
nnoremap <leader>gmt :G mergetool<CR>
nnoremap gdl :diffget //2<CR>
nnoremap gdr :diffget //3<CR>
nnoremap <leader>ghc :GitGutterLineHighlightsToggle<CR>
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
if !exists(":Gdiffoff")
command Gdiffoff diffoff | q | Gedit
endif
nnoremap <leader>gdo :Gdiffoff<CR>
""" Auto pairs
let g:AutoPairsFlyMode = 0
let g:AutoPairsMultilineClose = 0
" Complete
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Easy motion
map <Leader> <Plug>(easymotion-prefix)
function! MyHighlights() abort
" Define BadWhitespace before using in a match
highlight BadWhitespace ctermbg=red guibg=darkred
" Highlight spelling mistakes in red
highlight SpellBad cterm=underline ctermfg=red guifg=red
" Do not use separate background color in sign column
highlight SignColumn guibg=bg
highlight SignColumn ctermbg=bg
" Make background of error signs the same as a regular sign column
highlight CocErrorSign guifg=red
highlight CocErrorSign guibg=bg
highlight CocErrorSign ctermbg=bg
" Use underlined, bold, green for current tag
highlight TagbarHighlight guifg=#b8bb26
highlight TagbarHighlight gui=bold,underline
" Highlight search results in bold green
highlight Search guibg=guibg guifg=#b8bb26 gui=bold,underline cterm=bold,underline
" Try to use more subdued colors in vimdiff mode
highlight DiffAdd cterm=bold ctermfg=142 ctermbg=235 gui=NONE guifg=#b8bb26 guibg=#3c3c25
highlight DiffChange cterm=bold ctermfg=108 ctermbg=235 gui=NONE guifg=#8ec07c guibg=#383228
highlight DiffText cterm=NONE ctermfg=214 ctermbg=235 gui=NONE guifg=#fabd2f guibg=#483D28
highlight DiffDelete cterm=bold ctermfg=167 ctermbg=235 gui=NONE guifg=#fb4934 guibg=#372827
endfunction
augroup MyColors
autocmd!
autocmd ColorScheme * call MyHighlights()
augroup END
" Airline
let g:airline_theme='onedark'
" Vim test
if has('nvim')
tmap <C-o> <C-\><C-n>
endif
" Telescope
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fs <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>p <cmd>Telescope git_files<cr>
nnoremap <leader>fgb <cmd>Telescope git_branches<cr>
nnoremap <leader>fgc <cmd>Telescope git_commits<cr>