-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
271 lines (211 loc) · 6.23 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
" ============================================================================ "
" "
" --------- vim ------- "
" "
" ============================================================================ "
" Mapping
let mapleader=","
" easymotion trigger with only 1 leader
map <Leader> <Plug>(easymotion-prefix)
" dvorak window focus move
nnoremap <Space> <NOP>
nmap <silent> <Space>h :wincmd h<CR>
nmap <silent> <Space>t :wincmd j<CR>
nmap <silent> <Space>n :wincmd k<CR>
nmap <silent> <Space>s :wincmd l<CR>
" auto indent paste
nnoremap p p=`]
nnoremap <S-t> <S-p>=`]
" select pasted text
nnoremap gp `[v`]
if has("unix")
let s:uname = system("uname -s")
if s:uname == "Darwin\n"
nnoremap þ :m .+1<CR>==
nnoremap ñ :m .-2<CR>==
inoremap þ <Esc>:m .+1<CR>==gi
inoremap ñ <Esc>:m .-2<CR>==gi
vnoremap þ :m '>+1<CR>gv=gv
vnoremap ñ :m '<-2<CR>gv=gv
endif
endif
" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif
" Plugins
filetype off
if empty(glob('~/.vim/plugged'))
autocmd VimEnter * PlugInstall --sync
endif
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'morhetz/gruvbox'
Plug 'SirVer/ultisnips'
Plug '42Zavattas/vim-snippets'
Plug 'Raimondi/delimitMate'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'airblade/vim-gitgutter'
Plug 'easymotion/vim-easymotion'
Plug 'scrooloose/nerdcommenter'
Plug 'w0rp/ale'
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'mxw/vim-jsx'
Plug 'tomlion/vim-solidity'
Plug 'flowtype/vim-flow'
Plug 'jparise/vim-graphql'
Plug 'ap/vim-css-color'
call plug#end()
filetype plugin indent on
" Aliases
command Sp set paste
command Np set nopaste
command Pretty :%!jq .
" Need explanation?
syntax on
" Colors
colorscheme gruvbox
set background=dark
" Transparent bg <3
hi Normal ctermbg=NONE
set mouse=c
" Encoding, etc.
set encoding=utf-8
set termencoding=utf-8
" Correct strange bug
set backspace=indent,eol,start
" Insert space characters whenever <tab> is pressed
set expandtab
" Number of spaces inserted when hitting <tab>
set tabstop=2
" Number of spaces inserted when using :retab
set shiftwidth=2
" Don't wrap long lines
set nowrap
" Always show status bar
set laststatus=2
" Number of lines to keep above & below cursor when scrolling
set sidescrolloff=15
set sidescroll=1
set scrolloff=8
" Auto reload files when changed
set autoread
" Show the 80 chars column
set colorcolumn=80
" Don't create useless files
set noswapfile
set nobackup
set nowb
" Hide unsaved buffers
set hidden
" Show cursor line
set cursorline
" Move on search
set incsearch
" Show line numbers
set number
" Show infos in status bar
set ruler
" Prevent annoying highlight on search
set nohlsearch
" More intelligent searches
set ignorecase
set smartcase
" Never use Ex useless mode
nnoremap Q <ESC>
" Show blank characters
set listchars=tab:>-,trail:·,nbsp:%
set list
" Opening tab completion
set wildmode=longest,full
set wildignore=*.o,*.obj,*~
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=*node_modules*
set wildignore+=*ios*
set wildignore+=*android*
set wildignore+=*plugins*
set wildignore+=*platforms*
set wildignore+=*release*
set wildignore+=*coverage*
set wildignore+=*dist*,*dist-server*
set wildmenu
" Visual helpers
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
autocmd VimResized * :wincmd =
highlight link xmlEndTag xmlTag
" Line
let g:airline_powerline_fonts = 1
" Flow
let g:flow#enable = 0
" Ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" Vim JSX
let g:jsx_ext_required = 0
" NerdCommenter
let g:NERDSpaceDelims = 1
let g:NERDTrimTrailingWhitespace = 1
let g:NERDDefaultAlign = 'left'
" FZF
let g:fzf_layout = { 'down': '~50%' }
nnoremap <c-f> :Find<space>
nnoremap <Leader>f :Find<space><C-r><C-w><cr>
nnoremap <expr> <C-p> (len(system('git rev-parse')) ? ':Files' : ':GFiles --exclude-standard --others --cached')."\<cr>"
" custom files preview
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, <bang>0)
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'] }
" create file with subdirectories if needed :E
function s:MKDir(...)
if !a:0
\|| stridx('`+', a:1[0])!=-1
\|| a:1=~#'\v\\@<![ *?[%#]'
\|| isdirectory(a:1)
\|| filereadable(a:1)
\|| isdirectory(fnamemodify(a:1, ':p:h'))
return
endif
return mkdir(fnamemodify(a:1, ':p:h'), 'p')
endfunction
command -bang -bar -nargs=? -complete=file E :call s:MKDir(<f-args>) | e<bang> <args>
" ale
let js_fixers = ['prettier', 'eslint']
" let g:ale_linters = { 'javascript': ['eslint'], 'typescript': ['eslint'] }
" let g:ale_fixers = { 'javascript': , 'typescript': ['prettier'] }
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': js_fixers,
\ 'javascript.jsx': js_fixers,
\ 'typescript': js_fixers,
\ 'typescriptreact': js_fixers,
\ 'css': ['prettier'],
\ 'json': ['prettier'],
\}
let g:ale_fix_on_save = 1
let g:ale_sign_error = 'x'
let g:ale_sign_warning = '!'
let g:ale_javascript_prettier_use_local_config = 1
let g:ale_typescript_prettier_use_local_config = 1