-
Notifications
You must be signed in to change notification settings - Fork 4
/
.vimperatorrc
432 lines (376 loc) · 12.1 KB
/
.vimperatorrc
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
" Basic {{{
" GUIの設定
set gui=nonavigation
noremap v :set<Space>gui=nonavigation<CR>
noremap V :set<Space>gui=navigation<CR>
" 詳細表示を9行に
set verbose=9
" undo保持数
set! browser.sessionstore.max_tabs_undo=1000
" :tabopenの補完設定
set complete=lSt
" デフォルト検索エンジンの設定
set defsearch=g
" サジェストエンジンの設定
set suggestengines=g
" 履歴を保存
set history=100000
" リンクのURIをステータスラインに表示
set showstatuslinks=1
" ビープ音の無効化
set visualbell
hi Bell display:none
" キャレットを太くする
set! ui.caretWidth=8
" コマンドラインに入ったとき日本語入力を自動で無効に
style -name commandline-ime chrome://* #liberator-commandline-command input {ime-mode: inactive;}
" リンクのURIをコマンドラインに表示
set showstatuslinks=2
" 検索を強制的に設定
set! accessibility.typeaheadfind=false
set! accessibility.typeaheadfind.casesensitive=2
set! findbar.highlightAll=false
set! findbar.entireword=false
set! findbar.modalHighlight=false
" To Enable map <Space>
js <<EOM
window.addEventListener('keypress', function (event) {
var code = event.charCode;
if ((liberator.mode === modes.INSERT && modes.extended === modes.MENU)
||(liberator.mode == modes.NORMAL && code == 32)
||(liberator.mode == modes.COMMAND_LINE && code != 32)){
let map = mappings.get(liberator.mode, events.toString(event));
if (map) {
event.preventDefault();
event.stopPropagation();
map.execute();
}
}
}, false);
EOM
" My Customization
map <Space> <Leader>
" }}}
" bmarks {{{
bmark -title="Google" -tags=keyword -keyword=g https://www.google.co.jp/search?q=%s
bmark -title="niconico" -tags=keyword -keyword=nico http://www.nicovideo.jp/tag/%s
bmark -title="googlemap" -tags=keyword -keyword=map https://maps.google.co.jp/maps?q=%s
bmark -title="yahoo1" -tags=keyword -keyword=yahoo1 http://auctions.search.yahoo.co.jp/search?p=%s
bmark -title="twitter" -tags=keyword -keyword=t https://twitter.com/search?src=typd&q=%s
bmark -title="Qiita" -tags=keyword -keyword=qiita http://qiita.com/search?q=%s
bmark -title="Wikipedia" -tags=keyword -keyword=w https://ja.wikipedia.org/wiki/%s
bmark -title="twitter" -tags=keyword -keyword=t https://twitter.com/search?src=typd&q=%s
" }}}
" KeyBind {{{
" hとlでタブ移動
nnoremap h :tabprevious<CR>
nnoremap l :tabnext<CR>
" 移動量の設定
map j 5<C-e>
map k 5<C-y>
" コマンドライン
cmap <C-n> <Tab>
cmap <C-p> <S-Tab>
cmap <C-f> <Right>
cmap <C-b> <Left>
cmap <C-y> <S-Insert>
" Mac用 (Windowsは<A-*>)
cmap <M-n> <Down>
cmap <M-p> <Up>
noremap d :tabclose -select lastactive<CR>
" コマンドラインの補完
abbrev -j .title '"' + buffer.title + '"'
abbrev -j .url buffer.URL
abbrev -j .tu abbreviations.get(modes.INSERT, '.title').text + ' - ' + buffer.URL
set hintchars=HJKLASDFGYUIOPQWERTNMZXCVB
" 貼り付け無効
noremap p <NOP>
noremap P <NOP>
" M-pを無効
noremap <M-p> <NOP>
" undo一覧から開く
nnoremap U :undo<Space>
" タブ順序変更
noremap K :tabmove! -1<CR>
noremap J :tabmove! +1<CR>
" nohlsearch[
" nnoremap <ESC> :nohlsearch<CR><ESC>
set nohlsearch
" はてブコメント
command hatebu javascript liberator.open('http://b.hatena.ne.jp/entry/' + buffer.URL, liberator.NEW_TAB)
noremap <leader>b :hatebu<CR>
" yankにcopyプラグインを使う
noremap y :copy url<CR>
"}}}
" Patch {{{
javascript <<EOM
// Vimperator のコマンドラインバグをもんやり修正するバッチ
liberator.registerObserver(
'enter',
function () {
plugins.libly.$U.around(
commandline,
'input',
function (next, [prompt, callback, extra]) {
if (callback === finder.closure.onSubmit)
return next();
if (extra && (extra.onChange === hints.closure._onInput))
return next();
setTimeout(function () next(), 0);
}
);
if (plugins.xHint) {
[commands.get('xhint'), commands.get('xhintdo')].forEach(function (cmd) {
plugins.libly.$U.around(
cmd,
'action',
function (next) setTimeout(function () next(), 0)
);
});
}
}
);
EOM
" }}}
" Plugin {{{
"============================
" open-chrome
"============================
noremap <leader>ch :chrome<CR>
"============================
" open-blisk
"============================
" noremap <leader>bl :blisk<CR>
"============================
" appendAnchor
"============================
let g:auto_append_anchor = 1
"============================
" ime_controller
"============================
let g:ex_ime_mode="inactive"
let g:textarea_ime_mode="auto"
"============================
" copy
"============================
javascript <<EOM
liberator.globalVariables.copy_templates = [
{ label: 'url', value: '%URL%' },
{ label: 'twitter', value: '"%TITLE%" - %URL%' },
{ label: 'markdown', value: '[%TITLE%](%URL%)' },
{ label: 'titleAndURL', value: '%TITLE%\n%URL%' },
{ label: 'title', value: '%TITLE%' },
{ label: 'anchor', value: '<a href="%URL%">%TITLE%</a>' },
{ label: 'selanchor', value: '<a href="%URL%" title="%TITLE%">%SEL%</a>' },
{ label: 'htmlblockquote', value: '<blockquote cite="%URL%" title="%TITLE%">%HTMLSEL%</blockquote>' }
];
EOM
noremap <leader>cpt :copy twitter<Return>
noremap <leader>cpm :copy markdown<Return>
"============================
" feedSomeKeys_3
"============================
command! -nargs=+ lazy autocmd VimperatorEnter .* <args>
lazy fmaps -u='www\.google\.co\.jp\/search.*' j k v p o : s ? + i
lazy fmaps -u='mail\.google\.com/mail' c / j k n p o e x r # [ ] ? gi gs gt gd ga gc
lazy fmaps -u='mail\.google\.com/mail/.*/[0-9a-f]+$' c / j,n k,p n,j p,k o u e x s r a # [ ] ? gi gs gt gd ga gc
lazy fmaps -u='github\.com/.*' -events=vkeydown <C-b>
"============================
" ldr_cooperation
"============================
let g:ldrc_captureMappings = "['T', 'h', 'l', 'j', 'k', 'p', 'o', '?']"
let g:ldrc_hints = "true"
let g:ldrc_intelligence_bind = "true"
let g:ldrc_skip = "0.25"
"============================
" twittperator
"============================
noremap <leader>t :tw!<space>
noremap <leader>T :tw<space>
" let g:twittperator_use_chirp = 1
let g:twittperator_use_ssl_connection_for_api_ep = 1
" let g:twittperator_track_words = ""
" map s :js toggleSidebar('viewTwitterSidebar')<Return>
"============================
" toggleTreeTab
"============================
let g:treetabwidth=120
noremap a :toggletreetab<Return>
"============================
" multi_requester
"============================
noremap <leader>a :mr alc<space>
"============================
" jquery_loader
"============================
let g:jquery_filepath = "~/.vimperator/scripts/jquery-2.0.3.min.js"
"============================
" stylish
"============================
noremap <leader>s :stylish turnall<CR>
" }}}
" Plugin JS {{{
javascript <<EOM
// stella
function addLocalMappings(buffer, maps) {
maps.forEach(
function (map) {
let [cmd, action, extra] = map;
let actionFunc = action;
extra || (extra = {});
if (typeof action == "string") {
if (action.charAt(0) == ':')
actionFunc = extra.open ? function () commandline.open("", action, modes.EX)
: function () liberator.execute(action);
else
actionFunc = function () events.feedkeys(action, extra.noremap, true);
}
extra.matchingUrls = buffer;
mappings.addUserMap(
[modes.NORMAL],
[cmd],
"Local mapping for " + buffer,
actionFunc,
extra
);
}
);
}
addLocalMappings(
/^(http:\/\/(es|www).nicovideo.jp\/watch|http:\/\/(jp|www)\.youtube\.com\/watch|http:\/\/(www\.)?vimeo\.com\/(channels\/(hd)?#)?\d+)/,
[
['<C-g>', ':pageinfo S', ],
['p', ':stplay', ],
['m', ':stmute', ],
['c', ':stcomment', ],
['zz', ':stlarge', ],
['r', ':strepeat', ],
['+', ':stvolume! 10', ],
['-', ':stvolume! -10', ],
['h', ':stseek! -10', ],
['l', ':stseek! 10', ],
['k', ':stvolume! 10', ],
['j', ':stvolume! -10', ],
['s', ':stseek ', {open: true}],
['S', ':stseek! ', {open: true}],
['v', ':stvolume ', {open: true}],
['V', ':stvolume! ', {open: true}],
['o', ':strelations ', {open: true}],
['O', ':strelations! ', {open: true}],
]
);
// Fuzzy Tab Switch
liberator.modules.mappings.addUserMap(
[liberator.modules.modes.NORMAL],
["<C-f>"],
"Fuzzy Tab Switch",
function(argument){
tab_length = liberator.modules.tabs.count;
if(isNaN(input = parseInt(argument))){
switch(argument){
case "a": input = 1; break;
case "s": input = 2; break;
case "d": input = 3; break;
case "f": input = 4; break;
case "g": input = 5; break;
case "h": input = 6; break;
case "j": input = 7; break;
case "k": input = 8; break;
case "l": input = 9; break;
case ";": input = 0; break;
defalut:
liberator.echoerr("Invalid input.");
return;
}
}
if(input == 0) input = 10;
input == 1 ? fuzzy_tab_index = 1 : fuzzy_tab_index = Math.round(tab_length * input / 10);
liberator.modules.tabs.select(fuzzy_tab_index -1);
},
{
arg: true
//flags: liberator.modules.Mappings.flags.ARGUMENT
}
);
// double-meow-C-a.js
// mappings.addUserMap(
// [modes.COMMAND_LINE],
// ['<C-a>'],
// 'Go to head.',
// function () {
// let e = Editor.getEditor();
// let m = e.value.match(/^\s*\S+\s/);
//
// if (!m) {
// editor.executeCommand("cmd_beginLine", 1);
// return;
// }
//
// if (e.selectionStart <= m[0].length) {
// editor.executeCommand("cmd_beginLine", 1);
// return;
// }
//
// editor.executeCommand("cmd_beginLine", 1);
// editor.executeCommand("cmd_wordNext", 1);
// editor.executeCommand("cmd_charNext", 1);
// },
// {}
// );
mappings.addUserMap(
[modes.COMMAND_LINE],
['<M-b>'],
'word previous',
function () {
editor.executeCommand("cmd_wordPrevious", 1);
},
{}
);
mappings.addUserMap(
[modes.COMMAND_LINE],
['<M-f>'],
'word next',
function () {
editor.executeCommand("cmd_wordNext", 1);
editor.executeCommand("cmd_charNext", 1);
},
{}
);
EOM
js << EOM
let evaluateXPath = util.evaluateXPath || buffer.evaluateXPath;
mappings.addUserMap(
[modes.NORMAL],
[',p'],
'Toggle AutoPagerize',
function (motion, count, arg) {
buffer.followLink(
evaluateXPath('id("autopagerize_help")/div/a[@class="autopagerize_link"]').snapshotItem(0)
);
},
{}
);
EOM
" }}}
" After {{{
" テーマ設定
source ~/.vimperator/colors/sweets_dita.css
"============================
" buftabs
"============================
set showstatuslinks=1
javascript <<EOM
var adbar = document.getElementById('GiT-addon-bar');
var toggleButton = document.getElementById('GiT-addon-bar-toggle-button');
adbar.removeChild(toggleButton);
adbar.height=20;
EOM
loadplugins
set buftabs
" ツリー型タブがコマンドラインの上に重なるのを修正
style! -name=treestyletab chrome://* .tabbrowser-tab { z-index: 0 !important; }
" bug fix
" https://github.com/vimperator/vimperator-labs/issues/590#issuecomment-248833125
js services.services.autoCompleteSearch.class_="@mozilla.org/autocomplete/search;1?name=unifiedcomplete"
" }}}
" vim:set expandtab shiftwidth=2 softtabstop=2 tabstop=2 foldenable foldmethod=marker: