-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
392 lines (322 loc) · 9.4 KB
/
vimrc
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
" vimrc file for Hyunchel Kim {{{
let mapleader = ' '
let maplocalleader = '\\'
" }}}
" Basic settings {{{
" colors
set termguicolors
colorscheme NeoSolarized
set background=dark
syntax enable
" vimwiki
set nocompatible
filetype plugin on
" enable smart. ripgrep defaults to smartcase.
set ignorecase
set smartcase
" neosolarized
set t_8f=[38;2;%lu;%lu;%lum
set t_8b=[48;2;%lu;%lu;%lum
" the tabs
set tabstop=4
set shiftwidth=4
set expandtab
filetype indent on
set splitbelow
set splitright
" misc
set hlsearch incsearch
set number
set relativenumber
set colorcolumn=100
" }}}
" Abbreviations {{{
iabbrev pdb; import pdb;pdb.set_trace()
iabbrev #!! #! /usr/bin/env bash
" }}}
" File settings {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
augroup filetype_python
autocmd!
autocmd Filetype python setlocal tabstop=4 shiftwidth=4
autocmd Filetype python nnoremap <buffer> <localleader>c I# <esc>j
autocmd FileType python :iabbrev <buffer> iff if:<left>
autocmd FileType python :iabbrev <buffer> ifname if __name__ == '__main__':
augroup END
augroup filetype_javascript
autocmd!
autocmd Filetype javascript setlocal tabstop=2 shiftwidth=2
autocmd Filetype javascript inoremap {<space> {<space><space>}<ESC>hi
autocmd FileType javascript :iabbrev <buffer> iff if ()<left>
augroup END
augroup filetype_javascriptreact
autocmd!
autocmd Filetype javascriptreact setlocal tabstop=2 shiftwidth=2
autocmd Filetype javascriptreact inoremap {<space> {<space><space>}<ESC>hi
autocmd FileType javascriptreact :iabbrev <buffer> iff if ()<left>
augroup END
augroup filetype_typescript
autocmd!
autocmd Filetype typescript setlocal tabstop=2 shiftwidth=2
autocmd Filetype typescript inoremap {<space> {<space><space>}<ESC>hi
autocmd FileType typescript :iabbrev <buffer> iff if ()<left>
augroup END
augroup filetype_typescriptreact
autocmd!
autocmd Filetype typescriptreact setlocal tabstop=2 shiftwidth=2
autocmd Filetype typescriptreact inoremap {<space> {<space><space>}<ESC>hi
autocmd FileType typescriptreact :iabbrev <buffer> iff if ()<left>
augroup END
augroup filetype_solidity
autocmd!
autocmd Filetype solidity setlocal tabstop=2 shiftwidth=2
autocmd Filetype solidity inoremap {<space> {<space><space>}<ESC>hi
augroup END
augroup filetype_html
autocmd!
autocmd Filetype html setlocal tabstop=2 shiftwidth=2
autocmd FileType html nnoremap <buffer> <localleader>f Vatzf
autocmd Filetype html inoremap <buffer> ><cr> ><esc>bf>%wywo</<esc>pi><esc>O
augroup END
augroup filetype_css
autocmd!
autocmd Filetype css setlocal tabstop=2 shiftwidth=2
autocmd Filetype css inoremap <buffer> : :;<esc>i<space>
augroup END
augroup filetype_scss
autocmd!
autocmd Filetype scss setlocal tabstop=2 shiftwidth=2
autocmd Filetype scss inoremap <buffer> : :;<esc>i<space>
augroup END
augroup filetype_vue
autocmd!
autocmd Filetype vue setlocal tabstop=2 shiftwidth=2
autocmd Filetype vue :iabbrev <buffer> vueinit
\ <template><cr></template><cr><cr><script><cr>
\export default {}<cr>
\</script><cr><cr><style><cr></style>
augroup END
augroup filetype_txt
autocmd!
autocmd BufNewFile,BufReadPost *.txt setlocal spell
augroup END
augroup filetype_md
autocmd!
autocmd Filetype md nnoremap / /\v\c
" "inside/around heading"
" autocmd FileType md onoremap <buffer> ih :<c-u>execute "normal! ?^\\(==\\|--\\)\\+$\r:nohlsearch\rkvg_"<cr>
" autocmd FileType md onoremap <buffer> ah :<c-u>execute "normal! ?^(==|--)\\+$\r:nohlsearch\rg_vk0"<cr>
" Statusline
" autocmd FileType md setlocal statusline=%l
augroup END
" }}}
" Statuslines {{{
"set statusline=%4l,%-4c " Row and Colum
"set statusline+=\ %P " Percentage
"set statusline+=\ %m%r%h " Flags(modified, readonly, help)
"set statusline+=%= " Switch to right side
"set statusline+=%f\ " Relative path to the file
" }}}
" Plugins {{{
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/goyo.vim'
Plug 'majutsushi/tagbar'
let g:tagbar_sort = 0
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'rust-lang/rust.vim'
Plug 'mattn/emmet-vim'
let g:user_emmet_install_global = 0
autocmd FileType html,css,javascript,javascriptreact,vue,typescript,typescriptreact EmmetInstall
Plug 'posva/vim-vue'
Plug 'yuezk/vim-js'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'ap/vim-css-color'
Plug 'cespare/vim-toml'
Plug 'tomlion/vim-solidity'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
if has('nvim')
Plug 'neovim/nvim-lspconfig'
endif
Plug 'vimwiki/vimwiki'
let g:vimwiki_list = [{
\ 'path': '~/wiki',
\ 'ext': '.md',
\ }]
let g:vimwiki_key_mappings = {
\'table_mappings': 0,
\'table_format': 0,
\'html': 0,
\}
let g:vimwiki_conceallevel = 0
let g:vimwiki_markdown_link_ext = 1
Plug 'tools-life/taskwiki'
let g:taskwiki_markup_syntax = 'markdown'
call plug#end()
" }}}
" Mappings {{{
nnoremap <space> <nop>
nnoremap / /\v
" Insert a new line
nnoremap <leader>o o<esc>
nnoremap <leader>O O<esc>
nnoremap <leader>s :update<cr>
nnoremap <leader>q :q<cr>
nnoremap <leader>Q :qa!<cr>
" Explore
nnoremap <leader>n :Explore<CR>
" Reopen last file
nnoremap <leader><space> :execute "leftabove vsplit " . bufname("#")<CR>
" Match trailing space
nnoremap <leader>w :match Error /\v\s+\n/ <cr>
nnoremap <leader>W :match<cr>
" Clear highlight
nnoremap <leader>c :nohlsearch<cr>
" Easy access to VIMRC file
nnoremap <leader>er :vsplit $MYVIMRC<cr>
nnoremap <leader>sr :source $MYVIMRC<cr>
" Browse quick-fix items
nnoremap <leader>k :cprevious<cr>
nnoremap <leader>j :cnext<cr>
nnoremap <leader>z :set invrnu invnu<CR>
xnoremap J :move '>+1<CR>gv-gv
xnoremap K :move '<-2<CR>gv-gv
" Plugins
nnoremap ., :TagbarToggle<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>p :GFiles<CR>
nnoremap <leader>h :Helptags<CR>
nnoremap <leader>r :History/<CR>
" window splits + fzf
nnoremap <leader>st :tab sp<cr>:GFiles<cr>
nnoremap <leader>ss :split<cr>:GFiles<cr>
nnoremap <leader>sv :vsplit<cr>:GFiles<cr>
nnoremap <leader>F :Rg<cr>
" Goyo
nnoremap <leader><ENTER> :Goyo<CR>
" Toggle paste
nnoremap <leader>v :set paste!<CR>
" futigive
nnoremap <leader>g :Git<CR>
" Go stuffs
nnoremap <leader>gb :GoBuild<CR>
nnoremap <leader>gr :GoRun<CR>
nnoremap <leader>gi :GoInfo<CR>
nnoremap <leader>gt :GoTest<CR>
nnoremap <leader>gtf :GoTestFunc<CR>
nnoremap <leader>gpt :GoPointsTo<CR>
nnoremap <leader>gk :GoKeyify<CR>
nnoremap <leader>gfs :GoFillStruct<CR>
nnoremap <leader>gie :GoIfErr<CR>k%w
" Search selected words
vnoremap <leader>/ y/<C-R>"<CR>
" Easy escape
inoremap jk <esc>
inoremap <esc> <nop>
" Auto-closings
inoremap {<CR> {<CR>}<ESC>O
inoremap (<CR> (<CR>)<ESC>O
inoremap [<CR> [<CR>]<ESC>O
" "inside next/last parentheses"
onoremap in( :<c-u>normal! f(vi(<cr>
onoremap il( :<c-u>normal! F)vi(<cr>
" "around next/last parentheses"
onoremap an( :<c-u>normal! f(va(<cr>
onoremap al( :<c-u>normal! F)va(<cr>
" "inside next/last curly brackets"
onoremap in{ :<c-u>normal! f{vi{<cr>
onoremap il{ :<c-u>normal! F}vi{<cr>
" "around next/last curly brackets"
onoremap an{ :<c-u>normal! f{va{<cr>
onoremap al{ :<c-u>normal! F}va{<cr>
" "inside next/last brackets"
onoremap in[ :<c-u>normal! f[vi[<cr>
onoremap il[ :<c-u>normal! F]vi[<cr>
" "around next/last brackets"
onoremap an[ :<c-u>normal! f[va[<cr>
onoremap al[ :<c-u>normal! F]va[<cr>
" "inside next/last quotes"
onoremap in' :<c-u>normal! f'vi'<cr>
onoremap il' :<c-u>normal! F'vi'<cr>
" "around next/last quotes"
onoremap an' :<c-u>normal! f'va'<cr>
onoremap al' :<c-u>normal! F'va'<cr>
" "inside next/last double quotes"
onoremap in" :<c-u>normal! f"vi"<cr>
onoremap il" :<c-u>normal! F"vi"<cr>
" "around next/last double quotes"
onoremap an" :<c-u>normal! f"va"<cr>
onoremap al" :<c-u>normal! F"va"<cr>
" vimwiki
nnoremap <leader>vwi :VimwikiIndex<CR>
nnoremap <leader>vwd :VimwikiDiaryIndex<CR>
nnoremap <leader>vwmd :VimwikiMakeDiaryNote<CR>
nnoremap <leader>vwgd :VimwikiDiaryGenerateLinks<CR>
" }}}
" Golang settings {{{
" vim-go options
let g:go_template_autocreate = 0
" GoPls
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Tagbar - gotags
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" }}}
" Miscellaneous {{{
" If installed using Homebrew
set rtp+=/usr/local/opt/fzf
" Goyo
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
set showmode
set showcmd
set scrolloff=5
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" }}}