-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
222 lines (205 loc) · 6.12 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
" ----------------------------------------
" VimPlug Scripts
" ----------------------------------------
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'tomasr/molokai'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'ntpeters/vim-better-whitespace'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ervandew/supertab'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Plug 'wakatime/vim-wakatime'
Plug 'mattn/emmet-vim'
Plug 'posva/vim-vue'
" Plug 'scrooloose/syntastic'
Plug 'Chiel92/vim-autoformat'
" Plug 'leafgarland/typescript-vim'
Plug 'chemzqm/vim-jsx-improve'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'peitalin/vim-jsx-typescript'
" Plug 'nvie/vim-flake8'
Plug 'editorconfig/editorconfig-vim'
call plug#end()
" ----------------------------------------
" Plugin Setting
" ----------------------------------------
"
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_python_checkers = ['flake8']
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:formatdef_eslint = '"SRC=eslint-temp-${RANDOM}.js; cat - >$SRC; eslint --fix $SRC >/dev/null 2>&1; cat $SRC | perl -pe \"chomp if eof\"; rm -f $SRC"'
let g:formatters_javascript = ['eslint']
" NERDCommenter
let g:NERDSpaceDelims = 1
" NERDTree
let NERDTreeIgnore = ['\.pyc$', '\.sw[po]$']
let NERDTreeShowHidden=1
let g:nerdtree_tabs_autoclose=1
" NERDTreeTabs
" let g:nerdtree_tabs_open_on_console_startup=1
let g:nerdtree_tabs_focus_on_files=1
" Airline
let g:airline_theme='molokai'
" Molokai
let g:molokai_original=1
let g:rehash256=1
" vim-indent-guides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=235
" vim-better-whitespace
let g:strip_whitespace_confirm=0
let g:strip_whitespace_on_save=1
let g:better_whitespace_filetypes_blacklist=['vim']
" GitGutter
let g:gitgutter_realtime=1
let g:gitgutter_enabled=1
let g:gitgutter_max_signs=50000
if exists('&signcolumn') " Vim 7.4.2201
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif
" fzf
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
let g:fzf_action = {
\ 'enter': 'tab split',
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_colors =
\{
\ 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment']
\}
command! -bang -nargs=* Rgi
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --ignore-case --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)
" ----------------------------------------
" Key Mapping
" ----------------------------------------
map <leader>n :call ToggleNERDTree()<CR>
map <leader>gbl :Gblame<CR>
map <leader>gdf :Gdiff<CR>
map <leader>gst :Gstatus<CR>
map <leader>glg :Glog<CR>
map <leader>gla :!git la<CR>
map <leader>bc :CSScomb<CR>
map <leader>ttr :ToggleStripWhitespaceOnSave<CR>
map <leader>a :Ack
map <leader>rr :%s/\r//g<CR>
map <leader>rs :%s/\t/ /g<CR>
map <leader>s :'<,'>sort<CR>
map <leader>su :'<,'>sort u<CR>
map <leader>st2 :set expandtab ts=2 sts=2 sw=2<CR>
map <leader>st4 :set expandtab ts=4 sts=4 sw=4<CR>
map <C-_> <leader>ci
map <C-l> :tabnext<CR>
map <C-h> :tabprev<CR>
map <C-j> :tabe
map <C-k> :q<CR>
map <C-p> :FZF<CR>
map <C-o> :Rgi<CR>
map <C-i> :Rg<CR>
nnoremap <F12> :call ToggleMouse()<CR>
" ----------------------------------------
" Global Setting
" ----------------------------------------
syntax on
set autoindent
set number
set ignorecase
set ruler
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set t_Co=256
set encoding=utf-8
set fileencodings=utf-8,cp950
set hlsearch
set incsearch
set showcmd
set smartindent
set cursorline
set colorcolumn=120
set textwidth=120
set showtabline=2
set list listchars=tab:\¦\ ,trail:.
set mouse=a
set ttymouse=xterm2
set clipboard=unnamed " sudo apt-get install vim-gtk
set ffs=unix
set diffopt=vertical
colorscheme molokai
" ----------------------------------------
" Customize Function
" ----------------------------------------
function! IsNerdTreeEnabled()
return exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
endfunction
function! ToggleMouse()
if &mouse == 'a'
if winnr('$') > 1
:only
endif
set nonu
set mouse-=a
set nolist
:GitGutterDisable
echo "Copy Mode enabled"
else
set nu
set mouse=a
set list
:GitGutterEnable
echo "Copy Mode disabled"
endif
endfunction
function! ToggleNERDTree()
if IsNerdTreeEnabled()
:NERDTreeClose
else
let g:NERDTreeWinSize=31
:NERDTree
endif
endfunction