/
vimrc
279 lines (234 loc) · 7.34 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
set shell=/bin/sh
let mapleader = ','
set nocompatible " Be iMproved
"set noimdisable
"autocmd! InsertLeave * set imdisable|set iminsert=1
"autocmd! InsertEnter * set noimdisable|set iminsert=1
let NERDTreeHijackNetrw = 0
filetype off
call plug#begin('~/.vim/plugged')
Plug 'Raimondi/delimitMate'
Plug 'mattn/emmet-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'bronson/vim-trailing-whitespace'
Plug 'vim-scripts/molokai'
Plug 'kien/ctrlp.vim'
Plug 'ap/vim-css-color'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-git'
Plug 'tpope/vim-rails'
Plug 'pangloss/vim-javascript'
Plug 'mmalecki/vim-node.js'
Plug 'vim-ruby/vim-ruby'
Plug 'terryma/vim-multiple-cursors'
Plug 'tmhedberg/matchit'
Plug 'scrooloose/nerdtree'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
Plug 'ervandew/supertab'
" Plug 'scrooloose/syntastic'
Plug 'airblade/vim-gitgutter'
Plug 'thoughtbot/vim-rspec'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'rking/ag.vim'
Plug 'Yggdroot/indentLine'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'tomtom/tcomment_vim'
Plug 'w0rp/ale'
" vuejs vue file
Plug 'darthmall/vim-vue'
call plug#end()
filetype plugin indent on
set t_Co=256
set mouse=a
set laststatus=2
color molokai
nmap zz ZZ
nmap <Space> :
"Vim indentLine
let g:indentLine_color_term = 239
" splitjoin
nmap gs gS
nmap gj gJ
" tcomment_vim
map <leader>c<space> gcc<esc>
au BufRead,BufNewFile {*.json.jbuilder,Gemfile,Rakefile,Vagrantfile,Thorfile,Procfile,Guardfile,config.ru,*.rake} set ft=ruby
" Toggle paste mode
nmap <silent> <F4> :set invpaste<CR>:set paste?<CR>
imap <silent> <F4> <ESC>:set invpaste<CR>:set paste?<CR>
" format the entire file
nnoremap <leader>f :normal! gg=G``<CR>
" cd to the directory containing the file in the buffer
"nmap <silent> <leader>cd :lcd %:h<CR>
" Some helpers to edit mode
" http://vimcasts.org/e/14
"nmap <leader>ew :e <C-R>=expand('%:h').'/'<cr>
"nmap <leader>es :sp <C-R>=expand('%:h').'/'<cr>
"nmap <leader>ev :vsp <C-R>=expand('%:h').'/'<cr>
"nmap <leader>et :tabe <C-R>=expand('%:h').'/'<cr>
" Toggle hlsearch with <leader>hs
nmap <leader>hs :set hlsearch! hlsearch?<CR>
nmap <leader>bi :Dispatch bundle install<CR>
nmap <leader>q :wq<CR>
""
""Plugin Mapping
""
" rails.vim rspec jump
nmap <Leader>a :A<CR>
nmap Y y$
" Easy window navigation
map <C-b>h <C-w>h
map <C-b>j <C-w>j
map <C-b>k <C-w>k
map <C-b>l <C-w>l
"let g:ctrlp_map = ''
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\',
\ }
nmap <leader>gs :Gstatus<CR>
nmap <leader>gd :Gdiff<CR>
nmap <leader>gc :Gcommit<CR>
nmap <leader>gp :Gpush<CR>
nmap <leader>gl :Dispatch git pull<CR>
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '\.rbc$', '\.rbo$', '\.class$', '\.o$', '\~$']
map <silent> <leader>n :NERDTreeToggle<CR> :NERDTreeMirror<CR>
" let g:syntastic_enable_signs = 1
" let g:syntastic_always_populate_loc_list = 0
" let g:syntastic_auto_loc_list = 0
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" let g:syntastic_ruby_checkers = [ 'mri']
" scss and sass slow open and save
" let g:syntastic_mode_map = { 'passive_filetypes': ['sass', 'scss'] }
let g:ale_sign_column_always = 1
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" RSpec.vim mappings
map <Leader>tt :call RunCurrentSpecFile()<CR>
map <Leader>ts :call RunNearestSpec()<CR>
map <Leader>tl :call RunLastSpec()<CR>
map <Leader>ta :call RunAllSpecs()<CR>
let g:rspec_command = "Dispatch rspec {spec}"
""
"" Basic Setup
""
set number " Show line numbers
set numberwidth=5
set ruler " Show line and column number
syntax enable " Turn on syntax highlighting allowing local overrides
set history=1000 "Store lots of :cmdline history
set showcmd "Show incomplete cmds down the bottom
set showmode "Show current mode down the bottom
set gcr=a:blinkon0
set visualbell "No sounds
set noerrorbells " don't beep
set autoread "Reload files changed outside vim
"set hidden " Allow un-saved buffers in background
set clipboard=unnamed " Share system clipboard.
"set fileencodings=utf8,cp936,gb18030,big5
"set splitright " Puts new vsplit windows to the right of the current
"set splitbelow " Puts new split windows to the bottom of the current
""
"" Whitespace
""
" ================ Turn Off Swap Files ==============
set noswapfile
set nobackup
set nowb
set nowrap " don't wrap lines
set backspace=indent,eol,start " backspace through everything in insert mode
" ================ Indentation ======================
set autoindent
set copyindent " copy the previous indentation on autoindenting
set smartindent
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
" Display tabs and trailing spaces visually
set list listchars=tab:»\ ,trail:·
""
"" Searching
""
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
""
"" Wild settings
""
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore librarian-chef, vagrant, test-kitchen and Berkshelf cache
set wildignore+=*/tmp/librarian/*,*/.vagrant/*,*/.kitchen/*,*/vendor/cookbooks/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
if has("gui_running")
set guioptions-=m
set guioptions-=T
set guioptions-=L
set guioptions-=r
set guioptions-=b
set showtabline=0
set guifont=Monaco\ for\ Powerline:h16,Inconsolata\ for\ Powerline:h14,Consolas:h14
set shell=/bin/zsh
end
"""
"""windows setting
"""
if has("win32")
"language messages zh_CN.utf-8
" set the menu & the message to English
set langmenu=en
let $LANG= 'en'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set guifont=Monaco\ for\ Powerline:h16,Inconsolata\ for\ Powerline:h12,Consolas:h12
"set guifont=Monaco\ for\ Powerline:h14,Ubuntu\ Mono\ derivative\ Powerline:h13,Consolas:h12
set gfw=YouYuan:h14,Microsoft_Yahei:h14
set fileformat=unix
end
let g:airline_powerline_fonts=1
let g:airline_theme = 'powerlineish'
"
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ 's' : 'S',
\ 'S' : 'S',
\ }
set diffopt+=vertical
if has('nvim')
tnoremap <Esc> <C-\><C-n>
tnoremap <C-b> <C-\><C-n>
tnoremap <C-w>h <C-\><C-n><C-w>h
tnoremap <C-w>j <C-\><C-n><C-w>j
tnoremap <C-w>k <C-\><C-n><C-w>k
tnoremap <C-w>l <C-\><C-n><C-w>l
else
set encoding=utf8
end
" Enables HTML/CSS syntax highlighting in your JavaScript file.
let g:javascript_enable_domhtmlcss = 1
let g:javascript_ignore_javaScriptdoc = 1