-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
281 lines (210 loc) · 7.85 KB
/
init.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
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
" _ _ _ _
" (_)_ __ (_) |___ _(_)_ __ ___
" | | '_ \| | __\ \ / / | '_ ` _ \
" | | | | | | |_ \ V /| | | | | | |
" |_|_| |_|_|\__(_)_/ |_|_| |_| |_|
"
" by [email protected]
"-------------------------------------------------------------------------------
" Remap for easy edit
"-------------------------------------------------------------------------------
" leader
let mapleader = ","
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>ec :e ~/dotfiles/coc.vim<CR>
nmap <silent> <leader>so :source $MYVIMRC<CR>
"-------------------------------------------------------------------------------
" vim-plug
"-------------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
" Apperance
Plug 'flazz/vim-colorschemes'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'joshdick/onedark.vim'
" Behavior
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-obsession'
" File
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree' |
\ Plug 'Xuyuanp/nerdtree-git-plugin' |
\ Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Editing
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'easymotion/vim-easymotion'
Plug 'raimondi/delimitmate'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'Yggdroot/indentLine'
" IDE
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'liuchengxu/vista.vim'
" Syntax
Plug 'sheerun/vim-polyglot'
Plug 'styled-components/vim-styled-components'
call plug#end()
"-------------------------------------------------------------------------------
" PLUGIN SETTINGS
"-------------------------------------------------------------------------------
" Color ------------------------------------------------------------------------
if (has("termguicolors"))
set termguicolors
endif
syntax on
colorscheme onedark
hi link jsModuleKeyword Identifier
hi link jsxComponentName Identifier
hi link jsxBraces Operator
hi link jsClassDefinition Identifier
hi link jsFlowObjectKey Identifier
hi Comment gui=italic
let g:onedark_terminal_italics=1
" Italic
" set t_ZH=[3m
" set t_ZR=[23m
" transparent bg
" autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE
" NERDTree ---------------------------------------------------------------------
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
let g:NERDTreeWinSize=35
let g:NERDTreeShowHidden=1
let g:NERDTreeIgnore=['\.git$']
" EasyMotion -------------------------------------------------------------------
let g:EasyMotion_do_mapping = 0 " Disable default mappings
let g:EasyMotion_smartcase = 1 " Turn on case-insensitive feature
" Airline ----------------------------------------------------------------------
let g:airline_theme='onedark'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#formatter = 'jsformatter'
" fzf --------------------------------------------------------------------------
" Define Rg
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden'
" COC --------------------------------------------------------------------------
source ~/dotfiles/coc.vim
let g:coc_global_extensions=['coc-json', 'coc-css', 'coc-tsserver', 'coc-flow', 'coc-prettier', 'coc-eslint' ]
" Polyglot ---------------------------------------------------------------------
let g:javascript_plugin_flow = 1
" Vista ------------------------------------------------------------------------
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
let g:vista_default_executive = 'coc'
let g:vista_fzf_preview = ['right:50%']
"-------------------------------------------------------------------------------
" GLOBAL SETTINGS
"-------------------------------------------------------------------------------
" Line paddings to cursor
set so=10
" width
set textwidth=80
" Space and Tab " Use 4 spaces instead of tab
set tabstop=2 " Column counts for tab
set shiftwidth=2 " Column counts for <<, >>
set softtabstop=2 " Space count for tab key in INSERT mode
set expandtab " Use spaces instead of tabs
set breakindent " Every wrapped line will continue visually indented
" Search
set wrapscan " Search wrap lines
set ignorecase " Search ignore case
set smartcase " /foo matches FOO and fOo, but /FOO only matches the former
set hlsearch " Enable search highlighting
" Any buffer can be hidden (keeping its changes) without write
set hidden
" Turn backup off, since most stuff is in git
set nobackup
set nowritebackup
set noswapfile
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Change keyboard layout to english in normal mode
set noimdisable
set iminsert=1
set imsearch=-1
" foo-bar as word
set iskeyword+=-
" Using the clipboard as the default register
set clipboard=unnamedplus
" Mouse
set mouse=n
" Fix typing mistakes
command! Vs vs
"-------------------------------------------------------------------------------
" KEY MAPPING
"-------------------------------------------------------------------------------
" j and k move around wrapped line
map j gj
map k gk
" Yank all
nmap ya :%y+<CR>
" Move lines
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
" Buffer
nmap <silent> <A-p> :bp<CR>
nmap <silent> <A-n> :bn<CR>
nmap <silent> <C-A-n> :tabnext<CR>
nmap <silent> <C-A-p> :tabprev<CR>
" Update
nmap <silent> <leader>w :update<CR>
" Syntax ----------------------------------------------------------------------
function! Pad(s,amt)
return a:s . repeat(' ',a:amt - len(a:s))
endfunction
function! SynStack ()
for item in synstack(line("."), col("."))
let gid = synIDtrans(item)
let sname = synIDattr(item, "name")
let gname = synIDattr(gid, "name")
let fg = synIDattr(gid, "fg#")
let bg = synIDattr(gid, "fg#")
echo Pad(sname, 15)." -> ".Pad(gname, 15)." BG: ".Pad(bg,7)." FG: ".fg
endfor
endfunction
map <silent> <leader>g :call SynStack()<CR>
map <silent> <leader>ht :so $VIMRUNTIME/syntax/hitest.vim<CR>
" Plugin ----------------------------------------------------------------------
" vim-plug
nmap <leader>pi :PlugInstall<CR>
nmap <leader>pc :PlugClean<CR>
nmap <leader>pu :PlugUpdate<CR>
" EasyMotion
nmap <space> <Plug>(easymotion-overwin-f)
map <leader>/ <Plug>(easymotion-sn)
omap <leader>/ <Plug>(easymotion-tn)
map <leader>j <Plug>(easymotion-j)
map <leader>k <Plug>(easymotion-k)
" fzf
nnoremap <expr> <C-n> (len(system('git rev-parse')) ? ':Files' : ':GFiles --exclude-standard --others --cached')."\<cr>"
nnoremap <C-e> :History<cr>
nnoremap <A-e> :Buffers<cr>
nnoremap <C-g> :Rg<CR>
" Comment
nmap <c-_> <S-v>gcgv<esc>
vmap <c-_> gcgv<esc>
" Vista
nmap <c-t> :Vista finder<cr>
" Toggle ----------------------------------------------------------------------
nmap <silent> <leader>th :setlocal hlsearch! hlsearch?<CR>
nmap <silent> <leader>tw :setlocal wrap!<CR>:setlocal wrap?<CR>
nmap <silent> <leader>tn :setlocal number!<CR>
nmap <silent> <leader>tp :setlocal invpaste paste?<CR>
nmap <silent> <leader>tb <Plug>MarkdownPreviewToggle
nmap <silent> <leader>ti :IndentLinesToggle<CR>
nmap <silent> <leader>tt :NERDTreeToggle<CR>
nmap <silent> <leader>tf :NERDTreeFind<CR>
nmap <silent> <leader>tc :set cursorline!<CR>
nmap <silent> <leader>ta :AirlineToggle<CR>
nmap <silent> <leader>to :Vista!!<Cr>