-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
312 lines (271 loc) · 7.61 KB
/
init.vim
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
"------------------------------------------------------------
"検索関係
"------------------------------------------------------------
"{{{
set ignorecase
set smartcase
set hlsearch
set incsearch
" Kでカーソル下の単語のhelpを引く
set keywordprg=:help
"}}}
"------------------------------------------------------------
"編集関係
"------------------------------------------------------------
"{{{
set shiftround
set autoindent
set autowrite
set backspace=indent,eol,start
set wrapscan
set showmatch
set matchtime=1
set wildmenu
set formatoptions+=mM
set nostartofline
set confirm
set virtualedit=block
set notimeout
set ttimeout ttimeoutlen=200
set noswapfile
set nobackup
set noundofile
set autochdir
set hidden
set matchpairs& matchpairs+=<:>
set spelllang=en,cjk
" ファイルを開いた時に,カーソル位置を最後にカーソルがあった位置まで移動
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"}}}
"------------------------------------------------------------
"表示関係
"------------------------------------------------------------
"{{{
set number
set nolist
set ambiwidth=double
set wrap
set display=lastline
set laststatus=2
set cmdheight=2
set showcmd
set title
set visualbell
set t_vb=
set foldmethod=marker
set conceallevel=0
set pumheight=15
set completeopt=menu
set termguicolors
set pumblend=20
set signcolumn=yes
" 不可視文字の表示を変更
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲
" タブ設定
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
"}}}
"
let g:home = expand('~')
let g:python_home = g:home . '/.pyenv/shims'
let g:python_host_prog = g:python_home . '/python2'
let g:python3_host_prog = g:python_home . '/python3'
call plug#begin('~/.nvim/plugged')
" util
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'editorconfig/editorconfig-vim'
Plug 'Shougo/denite.nvim'
Plug 'Shougo/neomru.vim'
Plug 'kassio/neoterm'
Plug 'thinca/vim-quickrun'
Plug 'reireias/vim-cheatsheet'
" appearance
Plug 'itchyny/lightline.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'haya14busa/vim-operator-flashy'
" edit
Plug 'ntpeters/vim-better-whitespace'
Plug 'cohama/lexima.vim'
Plug 'tomtom/tcomment_vim'
Plug 'sjl/gundo.vim'
Plug 'haya14busa/vim-edgemotion'
" text object
Plug 'kana/vim-operator-user'
Plug 'kana/vim-operator-replace'
Plug 'rhysd/vim-operator-surround'
" file explorer
Plug 'Shougo/defx.nvim'
Plug 'kristijanhusak/defx-icons'
Plug 'ryanoasis/vim-devicons'
Plug 't9md/vim-choosewin'
" highlight and indent
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/vim-easy-align'
" lsp
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'mattn/vim-goimports', {'for': 'go'}
Plug 'liuchengxu/vista.vim'
" suggets
" Plug 'github/copilot.vim'
" top page
Plug 'mhinz/vim-startify'
" markdown
Plug 'dhruvasagar/vim-table-mode', {'for': 'markdown'}
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'plantuml', 'vim-plug']}
" template
Plug 'mattn/sonictemplate-vim'
" snippet
Plug 'hrsh7th/vim-vsnip'
Plug 'hrsh7th/vim-vsnip-integ'
" integration browser
Plug 'tyru/open-browser-github.vim'
Plug 'vim-scripts/open-browser.vim'
Plug 'mattn/webapi-vim'
" integration https://carbon.now.sh
Plug 'kristijanhusak/vim-carbon-now-sh'
" color theme
Plug 'cocopon/iceberg.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'NLKNguyen/papercolor-theme'
" test
Plug 'vim-test/vim-test'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
" debug
Plug 'sebdah/vim-delve'
" sql
Plug 'mattn/vim-sqlfmt'
" help
Plug 'vim-jp/vimdoc-ja'
call plug#end()
filetype plugin indent on
for plugin in glob(g:home.'/.config/nvim/plugins/*', 1, 1)
execute "source " . plugin
endfor
" Help
set helplang=ja
" Color
set t_Co=256
syntax enable
set background=dark
" color schemes with plugin
colorscheme PaperColor
" Yの動作をDやCと同じにする
map Y y$
" <ESC>2回で検索後の強調表示を解除する
nnoremap <ESC><ESC> :nohl<CR><C-L>
" j k を表示行移動できるよう変更
nnoremap j gj
nnoremap k gk
" 検索後にジャンプした際に検索単語を画面中央に持ってくる
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" .vimrcを開く
nnoremap <Leader>ev :tabe $HOME/.config/nvim/init.vim<CR>
" .vimrcを再読み込み
nnoremap <Leader>rv :source $HOME/.config/nvim/init.vim<CR>
" ヤンクした文字列でカーソル位置の単語を置換
nnoremap <silent> cy ce<C-r>0<ESC>:let@/=@1<CR>:noh<CR>
vnoremap <silent> cy c<C-r>0<ESC>:let@/=@1<CR>:noh<CR>
nnoremap <silent> ciy ciw<C-r>0<ESC>:let@/=@1<CR>:noh<CR>
" systemのレジスタとヤンクを共有する場合はこっち
nnoremap <silent> <leader>y "*yy
nnoremap <silent> <leader>p "*p
vnoremap <silent> <leader>y "*y
" ウィンドウ幅の変更
nnoremap + 5<C-W>+
nnoremap _ 5<C-W>-
nnoremap > 5<C-W>>
nnoremap < 5<C-W><
" ウィンドウ移動に使用するのでsの元の機能を削除(ci)
nnoremap s <Nop>
" s + hjkl でウィンドウ間を移動
nnoremap sh <C-w>h
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sl <C-w>l
nnoremap sw <C-w>w
" ウィンドウそのものを移動
nnoremap sJ <C-w>J
nnoremap sK <C-w>K
nnoremap sL <C-w>L
nnoremap sH <C-w>H
" 次のタブに移動
nnoremap sn :tabn<CR>
" 前のタブに移動
nnoremap sp :tabp<CR>
" タブの作成
nnoremap st :<C-u>tabnew<CR>
" quickfix
map <C-N> :cnext<CR>
map <C-M> :cprevious<CR>
map <C-P> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
" location-list
map <C-;> :lnext<CR>
map <C-'> :lprevious<CR>
nnoremap <leader>z :lclose<CR>
" ビジュアルモードでインデント変更後に再選択
vnoremap < <gv
vnoremap > >gv
" インサートモード中でも隣のウィンドウに移動
inoremap <C-W><C-W> <ESC><C-W><C-W><ESC>
function! SplitTerminalFunc()
:sp
:wincmd j
:resize 5
:terminal
:startinsert
endfunction
" 上下分割して、ターミナルを起動
command! Splitterminal :call SplitTerminalFunc()
" ESCでターミナルモードから抜ける
tnoremap <silent> <ESC> <C-\><C-n>
"ファイルタイプに関係する設定
augroup filetypeds
autocmd!
autocmd BufNewFile,BufRead,BufReadPre *.{md,mkd,mark*} set filetype=markdown
autocmd BufNewFile,BufRead,BufReadPre *.{json} set filetype=json conceallevel=0
autocmd InsertEnter *.json setlocal conceallevel=0 concealcursor=
autocmd InsertLeave *.json setlocal conceallevel=0 concealcursor=inc
autocmd BufRead,BufNewFile *.scss set filetype=scss.css
autocmd FileType scss set iskeyword+=-
autocmd BufNewFile,BufRead,BufReadPre *.{nvim} set filetype=vim conceallevel=0
autocmd BufNewFile,BufRead *.dig set filetype=yaml
autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd Syntax yaml setl indentkeys-=<:> indentkeys-=0#
" python の場合 Shift + F で自動修正
" original http://stackoverflow.com/questions/12374200/using-uncrustify-with-vim/15513829#15513829
function! Preserve(command)
" Save the last search.
let search = @/
" Save the current cursor position.
let cursor_position = getpos('.')
" Save the current window position.
normal! H
let window_position = getpos('.')
call setpos('.', cursor_position)
" Execute the command.
execute a:command
" Restore the last search.
let @/ = search
" Restore the previous window position.
call setpos('.', window_position)
normal! zt
" Restore the previous cursor position.
call setpos('.', cursor_position)
endfunction
function! Autopep8()
call Preserve(':silent %!autopep8 -')
endfunction
autocmd FileType python nnoremap <S-f> :call Autopep8()<CR>
augroup END