-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
240 lines (219 loc) · 9.02 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
" ファイル読み込み時の文字コードの設定
set encoding=utf-8
" Vim script内でマルチバイト文字を使う場合の設定
scriptencoding utf-8
" vi互換モードは切る
if &compatible
set nocompatible
endif
"+---------------+
"| Run time path |
"+---------------+
" dein.vimに関するディレクトリ
let s:dein_dir = expand('~/.vim/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
let s:rc_dir = expand('~/dotfiles')
if has('vim_starting')
" 起動にかかる読み込み時のみ以下を実行
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
" dein.vimがcloneされていない場合はcloneする
execute '!git clone https://github.com/Shougo/dein.vim ' . s:dein_repo_dir
endif
" runtimepathの先頭にdein.vimを追加
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif
endif
if dein#load_state(s:dein_dir)
" キャッシュされたdeinの状態を読み込めなかった場合だけ以下を実行
call dein#begin(s:dein_dir)
" 必ず読み込むプラグインのリスト
call dein#load_toml(s:rc_dir . '/dein.toml', { 'lazy': 0 })
" 状況に応じて読み込むプラグインのリスト
call dein#load_toml(s:rc_dir . '/dein_lazy.toml', { 'lazy': 1 })
call dein#end()
" 次回起動時のために状態をキャッシュする
call dein#save_state()
endif
if dein#check_install()
" インストールされていないパッケージがある場合にはインストールを行う
call dein#install()
endif
"+----------------------+
"| Vim default settings |
"+----------------------+
" シンタックスハイライトをON
syntax enable
" 行番号を表示
set number
" マッチするカッコを強調表示
set showmatch matchtime=1
" タブと行の折り返しを可視化
set list listchars=tab:>\ ,extends:<
" 常にタブをスペースに展開
set tabstop=4 " 画面上でタブ文字が占める幅
set shiftwidth=4 " smartindentで増減する幅
set expandtab " タブ入力を複数の空白入力に置き換える
set smarttab
" 自動インデントをON
set smartindent " 改行時に前の行の構文をチェックし次の行のインデントを増減する
" 新しいウィンドウを開く際に現在のウィンドウの位置が変わらないように
set splitright
set splitbelow
" バックアップファイルを作成しない
set nobackup
" 検索でマッチしたワードをハイライト
set hlsearch
" インクリメンタルサーチを有効化
set incsearch
" 大文字を含まない文字列での検索では大文字小文字を区別しない
set ignorecase " 検索パターンに大文字小文字を区別しない
set smartcase " 検索パターンに大文字を含んでいたら大文字小文字を区別する
" 常にステータスラインを表示
set laststatus=2
" 常にコマンドを表示
set showcmd
" \+pでPasteモードと切り替え
set pastetoggle=<leader>p
" Insertモード中に<BS>で直前の文字を消せるように
set backspace=indent,eol,start
" マーカーで折り畳む
set foldmethod=marker
" 常にコマンドを表示
set showcmd
" ヤンクをクリップボードに保持
set clipboard+=unnamed
set fileencoding=utf-8 " 保存時の文字コード
set fileencodings=ucs-boms,utf-8,euc-jp,cp932 " 読み込み時の文字コードの自動判別. 左側が優先される
set fileformats=unix,dos,mac " 改行コードの自動判別. 左側が優先される
set ambiwidth=double " □や○文字が崩れる問題を解決
set wildmenu " コマンドモードの補完
set history=5000 " 保存するコマンド履歴の数
"+--------------+
"| Key mappings |
"+--------------+
" Returnキーは常に新しい行を追加するように
noremap <CR> o<Esc>
" シェルのカーソル移動コマンドを有効化
" 折り返した行を複数行として移動
nnoremap <silent> j gj
nnoremap <silent> k gk
" ウィンドウの移動をCtrlキーと方向指定でできるように
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Esc2回で検索のハイライトを消す
nnoremap <silent> <Esc><Esc> :<C-u>nohlsearch<CR>
nnoremap <silent> <C-n> :NERDTreeToggle<CR>
" ツリーと編集領域を移動する
" nnoremap <C-t> <C-w>w
"+----------------+
"| Color settings |
"+----------------+
" 折り畳んだ箇所を行番号と同じ色にする
highlight Folded ctermfg=130 ctermbg=0
" enable 256 colors
set t_Co=256
"+----------------+
"| Other settings |
"+----------------+
" autocmd VimEnter * execute 'NERDTree'
" 不可視ファイルを表示する
let NERDTreeShowHidden = 1
" コーナーを + に変更
" let g:table_mode_corner_corner='+'
" ヘッダーの次の区切りを = にする
" let g:table_mode_header_fillchar='='
" terraform
let g:terraform_align=1
" -bオプションで起動した場合にバイナリ編集モードを有効化する
" original by KaWaZ (http://www.kawaz.jp/pukiwiki/?vim#ib970976)
augroup BinaryEditVimrcCommands
autocmd!
autocmd BufReadPre *.bin let &binary = 1
autocmd BufReadPost * if &binary | silent %!xxd -g 1
autocmd BufReadPost * set ft=xxd | endif
autocmd BufWritePre * if &binary | %!xxd -r | endif
autocmd BufWritePost * if &binary | silent %!xxd -g 1
autocmd BufWritePost * set nomod | endif
augroup END
" カーソルの位置を表すラインを必要なときだけ表示する
" original by thinca (http://d.hatena.ne.jp/thinca/20090530/1243615055)
augroup AutoCursorLineVimrcCommands
autocmd!
autocmd CursorMoved,CursorMovedI * call s:auto_cursorline('CursorMoved')
autocmd CursorHold,CursorHoldI * call s:auto_cursorline('CursorHold')
autocmd WinEnter * call s:auto_cursorline('WinEnter')
autocmd WinLeave * call s:auto_cursorline('WinLeave')
let s:cursorline_lock = 0
function! s:auto_cursorline(event)
if a:event ==# 'WinEnter'
setlocal cursorline
let s:cursorline_lock = 2
elseif a:event ==# 'WinLeave'
setlocal nocursorline
elseif a:event ==# 'CursorMoved'
if s:cursorline_lock
if 1 < s:cursorline_lock
let s:cursorline_lock = 1
else
setlocal nocursorline
let s:cursorline_lock = 0
endif
endif
elseif a:event ==# 'CursorHold'
setlocal cursorline
let s:cursorline_lock = 1
endif
endfunction
augroup END
" Renameで現在開いているファイルのファイル名を変更可能にする
" original by ujihisa (http://vim-jp.org/vim-users-jp/2009/05/27/Hack-17.html)
command! -nargs=1 -complete=file Rename f <args>|call delete(expand('#'))
"+--------------------+
"| File type settings |
"+--------------------+
" filetypeを有効にする
filetype plugin indent on
augroup FileTypeVimrcCommands
autocmd!
" NeoComplcacheのオムニ補完を有効化
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Esc2回でUniteウィンドウを閉じる
autocmd FileType unite nnoremap <buffer> <silent> <ESC><ESC> :q<CR>
autocmd FileType unite inoremap <buffer> <silent> <ESC><ESC> <ESC>:q<CR>
" Goでは行の折り返しだけを可視化
autocmd FileType go setlocal nolist
autocmd FileType go setlocal listchars=extends:<
" Rubyではタブをスペース2つに展開
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2
" SCSSではタブをスペース2つに展開
autocmd FileType scss setlocal tabstop=2 shiftwidth=2
" YAMLではタブをスペース2つに展開
autocmd FileType yaml setlocal tabstop=2 shiftwidth=2
" Gemfile, GuardfileをRubyファイルとして認識
autocmd BufRead,BufNewFile Gemfile setlocal filetype=ruby
autocmd BufRead,BufNewFile Guardfile setlocal filetype=ruby
" .coffeeをCoffeeScriptとして認識
autocmd BufRead,BufNewFile *.coffee setlocal filetype=coffee
" CoffeeScriptではタブをスペース2つに展開
autocmd FileType coffee setlocal tabstop=2 shiftwidth=2
" .llをLLVM-IRファイルとして認識
autocmd BufRead,BufNewFile *.ll setlocal filetype=llvm
" .inをOtterファイルとして認識
autocmd BufRead,BufNewFile *.in setlocal filetype=otter
autocmd Syntax otter source ~/.vim/bundle/Otter.vim/syntax/otter\[1\].vim
" TweetVim内でsを押すと新規ツイート作成
autocmd FileType tweetvim nnoremap <buffer> <silent> s :<C-u>TweetVimSay<CR>
" 常に文字数による自動改行は行わない
autocmd FileType * setlocal textwidth=0
augroup END
highlight Normal ctermbg=none
highlight NonText ctermbg=none
highlight LineNr ctermbg=none
highlight Folded ctermbg=none
highlight EndOfBuffer ctermbg=none