-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
331 lines (275 loc) · 8.6 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
" Remove existing autocommands for when the file is sourced twice
autocmd!
"-------------------------------------------------
" Dein.vim
if &compatible
set nocompatible
endif
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
call dein#begin('~/.cache/dein')
" Let dein manage dein
call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
call dein#add('AndrewRadev/vim-eco')
call dein#add('ctrlpvim/ctrlp.vim')
call dein#add('ivalkeen/vim-ctrlp-tjump')
call dein#add('Shougo/neomru.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/unite-help')
call dein#add('Shougo/unite-outline')
call dein#add('Shougo/unite.vim')
call dein#add('Shougo/vimproc.vim', {'build' : 'make'})
call dein#add('Shougo/vimshell')
call dein#add('cohama/lexima.vim')
call dein#add('fatih/vim-go')
call dein#add('flazz/vim-colorschemes')
call dein#add('hashivim/vim-terraform')
call dein#add('itchyny/lightline.vim')
call dein#add('leafgarland/typescript-vim')
call dein#add('mattn/ctrlp-matchfuzzy')
call dein#add('maxmellon/vim-jsx-pretty')
call dein#add('nathanaelkane/vim-indent-guides')
call dein#add('ntpeters/vim-better-whitespace')
call dein#add('pangloss/vim-javascript')
call dein#add('thinca/vim-qfreplace')
call dein#add('tpope/vim-fugitive')
call dein#add('tpope/vim-obsession')
call dein#add('tpope/vim-rhubarb')
call dein#add('tpope/vim-surround')
call dein#add('tyru/caw.vim')
call dein#add('vim-scripts/Align')
call dein#add('w0rp/ale')
call dein#end()
filetype plugin indent on
" If you want to install not installed plugins on startup.
"if dein#check_install()
" call dein#install()
"endif
"-------------------------------------------------
" Key Mappings
" Prefix
nnoremap [unite] <Nop>
nmap <Space>u [unite]
" Edit
inoremap <C-L> <ESC>
inoremap <silent> jj <ESC>
inoremap <silent> っj <ESC>
vnoremap <C-L> <ESC>
" IME
nnoremap あ a
nnoremap い i
nnoremap う u
nnoremap お o
" File, Window, Tab
nnoremap QQ :<C-u>q!<CR>
nnoremap <Space>w :<C-u>w<CR>
nnoremap <Space>q :<C-u>q<CR>
nnoremap <Space>Q :<C-u>bd<CR>
nnoremap <Space>n :<C-u>noh<CR>
nnoremap <Space>t :<C-u>tabnew<CR>
nnoremap <Space>e :<C-u>Explore<CR>
nnoremap <Space>s :<C-u>Sexplore<CR>
nnoremap <Space>h <C-w>h
nnoremap <Space>j <C-w>j
nnoremap <Space>k <C-w>k
nnoremap <Space>l <C-w>l
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <Space>m :<C-u>call <SID>MoveToNewTab()<CR>
nnoremap <c-]> :CtrlPtjump<cr>
vnoremap <c-]> :CtrlPtjumpVisual<cr>
function! s:MoveToNewTab()
tab split
tabprevious
if winnr('$') > 1
close
elseif bufnr('$') > 1
buffer #
endif
tabnext
endfunction
" surround.vim shortcuts
vmap { S{
vmap [ S[
vmap ( S(
vmap " S"
vmap ' S'
vmap ` S`
" Unite
nnoremap <silent> [unite]u :<C-u>Unite buffer file_mru<CR>
nnoremap <silent> [unite]y :<C-u>Unite -buffer-name=register register<CR>
nnoremap <silent> [unite]o :<C-u>Unite outline<CR>
nnoremap <silent> [unite]h :<C-u>Unite help<CR>
" Caw
nmap <Space>c <Plug>(caw:hatpos:toggle)
vmap <Space>c <Plug>(caw:hatpos:toggle)
"-------------------------------------------------
" Rendering Options
syntax enable
set t_Co=256
set background=dark
" colorscheme molokai
" colorscheme hybrid
colorscheme lucius
set ambiwidth=double " 全角記号文字の幅を設定
set breakindent
set breakindentopt=sbr
set showbreak=>\
set hlsearch
set incsearch
set laststatus=2
set noshowmode
set number
set scrolloff=3
" Performance improvements
set lazyredraw
set synmaxcol=300
"-------------------------------------------------
" General Options
" System
set belloff=all
set clipboard=unnamed
" Editor
set autoindent
set smarttab
set expandtab
set tabstop=2
set shiftwidth=2
set shiftround
set backspace=2
set whichwrap=b,s,<,>,[,],~
" Open Vim internal help by K command
set keywordprg=:Ggrep
" %キーでカッコとかdo-endとかに飛ぶ
if !exists('loaded_matchit')
runtime macros/matchit.vim
endif
" Open grep results in the quickfix-window
autocmd QuickFixCmdPost *grep* belowright cwindow
" Quickfix list launch file in a new tab
set switchbuf+=usetab,newtab
"-------------------------------------------------
" FileType settings
autocmd FileType vim call s:vim_filetype_settings()
function! s:vim_filetype_settings()
setlocal completeopt-=preview
setlocal keywordprg=:help
endfunction
autocmd FileType help call s:help_filetype_settings()
function! s:help_filetype_settings()
setlocal keywordprg=:help
endfunction
autocmd FileType ruby call s:ruby_filetype_settings()
function! s:ruby_filetype_settings()
setlocal tabstop=2 shiftround shiftwidth=2
setlocal completeopt-=preview
setlocal keywordprg=:Ggrep
endfunction
autocmd FileType go call s:go_filetype_settings()
function! s:go_filetype_settings()
setlocal tabstop=4 shiftwidth=4 softtabstop=4 noet
setlocal completeopt-=preview
setlocal keywordprg=:Ggrep
endfunction
" disable emphasis on markdown
autocmd FileType markdown hi! def link markdownItalic Normal
"-------------------------------------------------
" Neosnipet
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
"-------------------------------------------------
" Align
let g:Align_xstrlen = 3
"-------------------------------------------------
" Unite
let g:unite_enable_start_insert=1
call unite#custom#source('buffer,file_rec/git', 'matchers', 'matcher_fuzzy')
call unite#custom#source('buffer,file_rec/git', 'converters', 'converter_relative_abbr')
call unite#custom#source('buffer,file_rec/git', 'sorters', 'sorter_selecta') " may slower
call unite#custom#source('buffer,file_rec/git', 'ignore_pattern', '\(png\|gif\|jpeg\|jpg\)$')
"-------------------------------------------------
" IndentGuides
let g:indent_guides_enable_on_vim_startup=1
let g:indent_guides_guide_size=1
let g:indent_guides_start_level = 3
let indent_guides_color_change_percent = 5
let indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=darkgrey ctermbg=236
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=darkgrey ctermbg=237
"-------------------------------------------------
" Ale
" let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
let g:ale_sign_warning = '⚠'
let g:ale_sign_error = '✗'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%/%code%]'
let g:ale_lint_delay = 3000
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'go': ['gofmt', 'goimports'],
\}
" let g:ale_fix_on_save = 1
" 背景色が見づらいので desabled
let g:ale_set_highlights = 0
"-------------------------------------------------
" Lightline
" https://github.com/statico/dotfiles/blob/master/.vim/vimrc#L415
let g:lightline = {
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'filename', 'modified'],
\ ['linter_warnings', 'linter_errors', 'linter_ok'],
\ ]
\ },
\ 'inactive': {
\ 'left': [
\ ['relativepath', 'modified']
\ ]
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK'
\ },
\ 'component_type': {
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ }
\ }
function! LightlineLinterWarnings() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ⚠', all_non_errors)
endfunction
function! LightlineLinterErrors() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
endfunction
function! LightlineLinterOK() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✓ ' : ''
endfunction
autocmd User ALELint call lightline#update()
"-------------------------------------------------
" CtrlP
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_match_func = {'match': 'ctrlp_matchfuzzy#matcher'}