/
.vimrc
301 lines (236 loc) · 7.51 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
" syntax
syntax on
" ---------------------------------------
" encoding
" ---------------------------------------
scriptencoding utf-8
" ---------------------------------------
" dein
" ---------------------------------------
" dein.vimのディレクトリ
let s:dein_dir=expand('~/.cache/dein')
let s:dein_repo_dir=s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" なければgit clone
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
execute 'set runtimepath^=' . s:dein_repo_dir
if dein#load_state(shellescape(s:dein_dir))
call dein#begin(s:dein_dir)
let s:toml='~/.dein.toml'
let s:lazy_toml='~/.dein_lazy.toml'
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazy_toml, {'lazy': 1})
call dein#end()
call dein#save_state()
endif
" その他インストールしていないものはこちらに入れる
if dein#check_install()
call dein#install()
endif
autocmd VimEnter * call dein#call_hook('post_source')
" キーマップ
nmap du :call dein#update()<cr>
" ---------------------------------------
" File
" ---------------------------------------
set noswapfile
set nobackup
set noundofile
" ファイルが外部で変更された際に自動で読み込む
set autoread
" 未保存ファイルの終了時に保存確認を行なう
set confirm
" ファイル変更中に他のファイルを表示可能にする
set hidden
" ---------------------------------------
" Display
" ---------------------------------------
" [基本的な見た目]
" 編集中のファイル名を表示する
set title
" 行番号
set number
set relativenumber
" ルーラーを表示する
set ruler
" タブバーを常に表示する
set showtabline=2
" ステータスバーを常に表示する
set laststatus=2
" 折り返しなし
set nowrap
" 256色対応
set t_Co=256
" カーソル行の上下へのオフセットを設定する
set scrolloff=4
" デフォルトvimrc_exampleのtextwidth設定上書き
autocmd FileType text setlocal textwidth=0
" [文字表示関連]
" 文字コードを設定する
set encoding=utf8
set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis
" 不可視文字の表示方法を設定する
set listchars=eol:?
" 文字崩れの発生を抑止
set ambiwidth=single
" [強調]
" 検索結果をハイライト表示する
set hlsearch
" カーソル行を強調表示する
set cursorline
" 改行コードを非表示にする
set nolist
" 対応するカッコを強調表示する
set showmatch
" ---------------------------------------
" Action
" ---------------------------------------
" [インデント/タブ/スペース]
" 自動インデント
"set autoindent
set smartindent
" タブの代わりにスペースを挿入する
set expandtab
" インデントでずれる幅を設定する
set shiftwidth=2
" タブやバックスペースで処理するスペースの数を設定する
set softtabstop=2
" タブ幅を設定する
set tabstop=2
" コンテキストに応じたタブの処理を行なう
set smarttab
" [検索]
" 大文字と小文字を区別せず検索する
set ignorecase
" インクリメンタルサーチを有効にする
set incsearch
" [その他]
" 新しいウィンドウを下/右に開く
set splitbelow
set splitright
" バックスペースの影響範囲を設定する
set backspace=indent,eol,start
" OSとクリップボードを共有する
"set clipboard=unnamed,autoselect
set clipboard=unnamedplus
" マウスを有効にする
set mouse=a
" ビープを無効にする
set visualbell t_vb=
" 行頭・行末の左右移動で行を移動する
set whichwrap=b,s,h,l,<,>,[,]
" コマンドラインモードで保存する履歴数を設定する
set history=1000
" コマンドラインモードでの補完を有効にする
set wildmenu
" コマンドラインモードでの補完方法を設定する
set wildmode=list:longest,full
" 入力中のコマンドを表示する
set showcmd
" ファイルタイプ変更時に自動的にプラグインとインデント設定を読み込む
filetype plugin indent on
" ---------------------------------------
" キーマップ
" ---------------------------------------
" インサートモードから抜ける
inoremap <silent>jj <ESC>
" ターミナルモードでインサートモードから抜ける
tnoremap <ESC> <C-\><C-n>
" nvim時はterminalを明示的に分割するようにする
if has('nvim')
command! -nargs=* Term split | terminal <args>
endif
" 行頭移動を0でトグルする
noremap <expr> 0 getline('.')[0 : col('.') - 2] =~# '^\s\+$' ? '0' : '^'
" カッコ
inoremap {<Enter> {}<Left><CR><ESC><S-o>
inoremap [<Enter> []<Left><CR><ESC><S-o>
" ウィンドウ
nnoremap s <Nop>
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sl <C-w>l
nnoremap sh <C-w>h
nnoremap <silent> ss :<C-u>sp<CR>
nnoremap <silent> sv :<C-u>vs<CR>
nnoremap <silent> sn :<C-u>bnext<CR>
nnoremap <silent> sp :<C-u>bprevious<CR>
nnoremap <silent> sq :<C-u>bd<CR>
" q:、q/、q? は無効化する
:nnoremap q: <NOP>
:nnoremap q/ <NOP>
:nnoremap q? <NOP>
" クリップボードの内容で検索する
nnoremap g/ /\V<C-r>=join(map(getreg(v:register,1,1),{k,v->escape(v,'\/')}),'\n')<CR><CR>
" インサートモード中にペーストする
inoremap <expr> <C-v> printf('<C-r><C-o>%s', has('linux') \|\| has('unix') ? '+' : '*')
cnoremap <expr> <C-v> printf('<C-r><C-o>%s', has('linux') \|\| has('unix') ? '+' : '*')
" vimgrep
nnoremap [q :cprevious<CR> " 前へ
nnoremap ]q :cnext<CR> " 次へ
nnoremap [Q :<C-u>cfirst<CR> " 最初へ
nnoremap ]Q :<C-u>clast<CR> " 最後へ
" vimgrepの結果をQuickFixで開く
autocmd QuickFixCmdPost *grep* cwindow
" NORMALモードに戻るときにIMEをOFFにする
function! ImInActivate()
call system('fcitx-remote -c')
endfunction
inoremap <silent> jj <ESC>:call ImInActivate()<CR>
inoremap <silent> っj <ESC>:call ImInActivate()<CR>
" 保存時にsudo権限で無理やり保存
cnoremap w!! w !sudo tee > /dev/null %<CR> :e!<CR>
" ---------------------------------------
" Scala Setting
" ---------------------------------------
augroup MyScala
au BufRead,BufNewFile *.sbt,*.sc set filetype=scala
augroup END
" ---------------------------------------
" Json Setting
" ---------------------------------------
augroup MyJson
autocmd FileType json syntax match Comment +\/\/.\+$+
augroup END
" ---------------------------------------
" Rust Setting
" ---------------------------------------
augroup MyRust
autocmd!
autocmd BufWritePost *.rs silent !cargo fmt
augroup END
" ---------------------------------------
" Python Setting
" ---------------------------------------
" 設定方法
" インストール可能なPythonのバージョンを確認
" $ pyenv install --list
" インストール済みのPythonバージョンを確認
" $ pyenv versions
" python2環境
" $ pyenv install 2.X.X
" $ pyenv virtualenv 2.X.X neovim2
" $ pyenv activate neovim2
" $ pip2 install neovim
" $ pyenv which python
"
" python3環境
" $ pyenv install 3.X.X
" $ pyenv virtualenv 3.X.X neovim3
" $ pyenv activate neovim3
" $ pip install neovim
" $ pyenv which python
"
" .zshrc には以下の設定を
" export PYENV_ROOT="$HOME/.pyenv"
" export PATH="$PYENV_ROOT/bin:$PATH"
" eval "$(pyenv init -)"
" eval "$(pyenv virtualenv-init -)"
let g:python_host_prog = $PYENV_ROOT.'/versions/neovim2/bin/python'
let g:python3_host_prog = $PYENV_ROOT.'/versions/neovim3/bin/python'
" ---------------------------------------
" for Dev
" ---------------------------------------
"set runtimepath^=~/workspace/ts/denops-yankedhighlight
"let g:denops#debug = 1