-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.util
226 lines (176 loc) · 6.86 KB
/
.vimrc.util
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
""" .vimrc.util
"======================================================
" config for moving(cursor, window), utility plugins searching and so on
"======================================================
" 誤操作すると困るキーを無効化
" see : http://deris.hatenablog.jp/entry/2013/05/02/192415
" Invalid keys {{{
" 保存して閉じる
nnoremap ZZ <Nop>
" 保存せず閉じる
nnoremap ZQ <Nop>
" ex mode
nnoremap Q <Nop>
" }}}
" Moving cursor {{{
" moving last line's tail
nnoremap EE G $
" }}}
" Moving window {{{
" command modeでsキーprefixにしたウィンドウ間移動を行う
" <C-w>lなどでウィンドウ間を移動を行うと、自動的にウィンドウ横幅を修正
" see : http://vim-users.jp/2009/07/hack42/
nnoremap sh <C-w>h <C-w>h:call <SID>good_width()<Cr>
nnoremap sl <C-w>l <C-w>l:call <SID>good_width()<Cr>
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sH <C-w>H <C-w>H:call <SID>good_width()<Cr>
nnoremap sL <C-w>L <C-w>L:call <SID>good_width()<Cr>
function! s:good_width()
if winwidth(0) < 84
vertical resize 84
endif
endfunction
" }}}
" openbrowser.vim {{{
let g:netrw_nogx = 1 " disable netrw's gx mapping.
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" If it looks like URI, Open URI under cursor.
" Otherwise, Search word under cursor.
" nmap <Space>ob <Plug>(openbrowser-smart-search)
" vmap <Space>ob <Plug>(openbrowser-smart-search)
" }}}
" unite.vim {{{
" ,でunite.vimを起動
" see : http://mba-hack.blogspot.jp/2013/03/unitevim.html
" The prefix key .
nnoremap [unite] <Nop>
nmap , [unite]
let g:unite_enable_ignore_case = 1
let g:unite_enable_smart_case = 1
nnoremap <silent> [unite]f :<C-u>Unite<Space>buffer<CR>
nnoremap <silent> [unite]j :<C-u>Unite<Space>file_rec<CR>
" nnoremap <silent> [unite]r :<C-u>Unite<Space>bookmark<CR>
nnoremap <silent> [unite]m :<C-u>Unite<Space>file_mru<CR>
nnoremap <silent> [unite]b :<C-u>UniteWithBufferDir file<CR>
nnoremap <silent> [unite]o :<C-u>Unite<Space>outline<CR>
nnoremap <silent> ,vr :UniteResume<CR>
nnoremap <silent> [unite]g :<C-u>Unite grep -buffer-name=search-buffer<CR>
nnoremap <silent> [unite]cg :<C-u>Unite grep -buffer-name=search-buffer<CR><C-R><C-W>
nnoremap <silent> [unite]r :<C-u>UniteResume search-buffer<CR>
" use ag as Unite grep
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
" .gitignoreで指定したファイルと.git/以下のファイルを候補から除外する
function! s:unite_gitignore_source()
let sources = []
if filereadable($HOME.'/.agignore')
for file in readfile($HOME.'/.agignore')
" コメント行と空行は追加しない
if file !~ "^#\\|^\s\*$"
call add(sources, file)
endif
endfor
endif
if isdirectory('./.git')
call add(sources, '.git')
endif
let pattern = escape(join(sources, '|'), './|')
call unite#custom#source('file_rec', 'ignore_pattern', pattern)
call unite#custom#source('grep', 'ignore_pattern', pattern)
endfunction
call s:unite_gitignore_source()
" unite開いている時のキーマッピング
" see : http://www.karakaram.com/vimfiler
augroup vimrc
autocmd!
autocmd FileType unite call s:unite_my_settings()
augroup END
function! s:unite_my_settings()
"ESCでuniteを終了
nmap <buffer> <ESC> <Plug>(unite_exit)
" sでsplit
nnoremap <silent><buffer><expr> s unite#smart_map('s', unite#do_action('split'))
inoremap <silent><buffer><expr> s unite#smart_map('s', unite#do_action('split'))
" vでvsplit
nnoremap <silent><buffer><expr> v unite#smart_map('v', unite#do_action('vsplit'))
inoremap <silent><buffer><expr> v unite#smart_map('v', unite#do_action('vsplit'))
" fでvimfiler
nnoremap <silent><buffer><expr> f unite#smart_map('f', unite#do_action('vimfiler'))
inoremap <silent><buffer><expr> f unite#smart_map('f', unite#do_action('vimfiler'))
endfunction
" }}}
" vimfiler {{{
" see : http://www.karakaram.com/vimfiler
" vimデフォルトのエクスプローラをvimfilerに置き換える
let g:vimfiler_as_default_explorer = 1
" セーフモードを無効にした状態で起動
let g:vimfiler_safe_mode_by_default = 0
" 現在開いているバッファのディレクトリを開く
nnoremap <silent> <Leader>fe :<C-u>VimFilerBufferDir -quit<CR>
" 現在開いているバッファをIDE風に開く
nnoremap <silent> <Leader>fi :<C-u>VimFilerBufferDir -split -simple -winwidth=35 -no-quit<CR>
" デフォルトのキーマッピングを変更
" qキーでvimfilerを閉じる Qキーでvimfilerを隠す
augroup vimrc
autocmd!
autocmd FileType vimfiler call s:vimfiler_my_settings()
augroup END
function! s:vimfiler_my_settings()
nmap <buffer> q <Plug>(vimfiler_exit)
nmap <buffer> Q <Plug>(vimfiler_hide)
endfunction
" }}}
" buffer {{{
" function keys for buffer
" F2 previous buffer
nnoremap <F2> <ESC>:bp<CR>
" F3 next buffer
nnoremap <F3> <ESC>:bn<CR>
" F4 delete buffer
nnoremap <F4> <ESC>:bnext \| bdelete #<CR>
command! BufDel :bnext \|bdelete #
" }}}
" vimshell {{{
" vimshell split option
let g:vimshell_split_command = 'below split'
" }}}
" iexe-sbt {{{
function! s:vimrc_int_sbt()
syn match intsbtInfo '^\[info\]'
syn match intsbtError '^\[error\]'
syn match intsbtSuccess '^\[success\] .*'
syn match intsbtPrompt '^> '
hi def link intsbtInfo LineNr
hi def link intsbtError ErrorMsg
hi def link intsbtSuccess LineNr
hi def link intsbtPrompt vimshellUserPrompt
endfunction
augroup vimrc-int-sbt
autocmd!
autocmd FileType int-sbt call <SID>vimrc_int_sbt()
augroup END
" }}}
" syntastic {{{
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 2
let g:syntastic_check_on_wq = 0
" }}}
" vim-quickrun {{{
let g:quickrun_config = {}
if has('win32') || has('win64')
let g:quickrun_config._ = {'runner' : 'vimproc', 'hook/output_encode/encoding': 'sjis'}
else
let g:quickrun_config._ = {'runner' : 'vimproc'}
endif
let g:quickrun_config.xhtml = {'command': 'open', 'outputter': 'browser'}
let g:quickrun_config.html = deepcopy(g:quickrun_config.xhtml)
" }}}
" agit.vim {{{
" let g:agit_enable_auto_show_commit = 0
" let g:agit_enable_auto_refresh = 1
" }}}