-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimperatorrc
executable file
·426 lines (384 loc) · 12.6 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
" basic {{{1
set titlestring="Mozilla Firefox"
set verbose=9
set gui=none
set gui=tabs
set hintchars=hjklasdfgyuiopqwertnmzxcvb
set complete=tbsl
set ignorecase
set smartcase
set focuscontent
set newtab=all
set animations
set visualbell
set nextpattern=\bnext\b,\bmore\b,next,^次(の)?ページ,\b次.*,→\b,^>$,^(>>|≫)$,^(>|≫),(>|≫)$
set previouspattern=\bprev|previous\b,prev,^前(の)?ページ,\b前.*,\b←,^<$,^(<<|≪)$,^(<|≪),(<|≪)$
" editor
js <<EOM
if (liberator.has("MacUnix")) {
// Mac
liberator.execute("set editor='mvim -f'");
} else {
// Other
liberator.execute("set editor='gvim -f'");
}
EOM
" mappings {{{1
nnoremap <C-l> <C-n>
nnoremap <C-h> <C-p>
"nnoremap s <Nop>
nnoremap sn gt
nnoremap sp gT
nnoremap sq :<C-u>q<CR>
nnoremap sO :<C-u>tabonly<CR>
nnoremap d D
nnoremap D d
" window size
nmap [WIN] <NOP>
nnoremap <C-w> [WIN]
noremap [WIN]s :js window.outerWidth=800; window.outerHeight=600;<CR>
noremap [WIN]m :js window.outerWidth=1024; window.outerHeight=768;<CR>
noremap [WIN]l :js window.outerWidth=1280; window.outerHeight=960;<CR>
nnoremap w :winopen<Space>
" encode
nnoremap ee :setlocal encoding=EUC-JP<CR>
nnoremap ej :setlocal encoding=ISO-2022-JP<CR>
nnoremap es :setlocal encoding=Shift_JIS<CR>
nnoremap eu :setlocal encoding=UTF-8<CR>
nnoremap <S-u> :undo<space>
inoremap <C-n> <Down>
inoremap <C-p> <Up>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
" nohlsearch
"nnoremap <ESC><ESC> :nohlsearch<CR>
" command mode emacs keybindings
cnoremap <C-p> <S-Tab>
cnoremap <C-n> <Tab>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-k> <Up>
cnoremap <C-l> <Down>
" google search at selected text
vnoremap <silent> <C-g> y<Esc><Esc>P
" yank url
nnoremap <silent> y :javascript util.copyToClipboard(buffer.URL);<CR>:echo "Yanked " + util.readFromClipboard();<CR>
" reload vimperatorrc
nnoremap ,r :source ~/.vimperatorrc<CR>
nnoremap .r :restart<CR>
" Force ime off in hint mode
" noremap <silent> f :!fcitx-remote -c<CR>qf
" noremap <silent> F :!fcitx-remote -c<CR>qF
" style {{{1
" IME off at Hint
style! -name=commandline-ime chrome://* #liberator-commandline-command input { ime-mode: inactive; }
style! -name=textarea-ime * textarea,input { ime-mode: inactive; }
style! -name=disabled_fxlinkpopup chrome://* #statusbar-display[type="overLink"] { display: none !important; }
" for treestyletab
style! -name=treestyletab chrome://* .tabbrowser-tab { z-index: 0 !important; }
" colorscheme {{{1
" colorscheme theme
" colorscheme fix-addon
" colorscheme fix-firefox
colorscheme sweets_snaka
" colorscheme solarized_dark
hi -append Normal opacity: 0.8;
" http://chroju89.hatenablog.jp/entry/2014/02/09/102914
hi ErrorMsg color:white; background-color:#ec6aa1;
" hi Hint z-index:5000; font-size:14px; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 2px 0px 2px; position:absolute; font-family: Menlo, Consolas, Monaco, monospace; text-transform: uppercase;
hi CompTitle background: Orchid;
" quickmark {{{1
qmark 2 http://is.2ch.net/
qmark a https://affiliate.amazon.co.jp/gp/associates/network/main.html
qmark A https://www.google.com/analytics/web/?hl=ja&pli=1#report/visitors-overview/a47356782w84696412p87788910/
qmark b https://bitbucket.org/yukimemi
qmark c https://www.google.com/calendar/render?hl=ja
qmark d http://192.168.1.1/
qmark e https://www.evernote.com/Home.action
qmark f http://www.facebook.com/
qmark g https://www.google.com/adsense/v3/app#home
qmark G http://yukimemi.github.io
qmark h http://b.hatena.ne.jp/
qmark i https://www.icloud.com
qmark k http://yukimemi.bitbucket.org/
qmark l https://inbox.google.com
qmark m http://mixi.jp/home.pl
qmark o http://yukimemi.github.com
qmark p https://plus.google.com/
qmark P http://getpocket.com/a/queue/
qmark r http://cloud.feedly.com/
qmark T https://twitter.com
qmark t https://trello.com/
qmark u http://uhloop.com/
qmark v http://tv.yahoo.co.jp/listings/realtime/
qmark y http://www.youtube.com/?gl=JP&hl=ja
" ignorekeys"{{{1
" ignorekeys add mail\\.google\\.com -except :,F,t,O,<C-h>,<C-l>,<C-n>,<C-p>,gt,gT,d,D
" ignorekeys add plus\\.google\\.com -except :,t,f,F,d,D,g,<C-h>,<C-l>,<C-n>,<C-p>,gt,gT,gg,G,<C-[>
ignorekeys add feedly\\.com -except :,t,f,F,d,D,<C-h>,<C-l>,<C-n>,<C-p>,gt,gT,gg,G,<C-[>
ignorekeys add twitter\\.com -except :,f,F,d,D,<C-h>,<C-l>,<C-n>,<C-p>,gt,gT,gg,G,<C-[>
ignorekeys add pocket\\.com -except :,f,F,d,D,<C-h>,<C-l>,<C-n>,<C-p>,gt,gT,gg,G,<C-[>
" javascript {{{1
" Google search in the site {{{2
" http://blog.feelmy.net/2012/12/22/useful-tips-for-vimperator/
nnoremap ,/ :sitesearch<Space>
javascript <<EOM
commands.addUserCommand(
['sitesearch'],
'Search in this site',
function (args) {
let url = window.content.location.hostname;
[
/d\.hatena\.ne\.jp/,
/www\d+\.atwiki\.jp/,
].forEach(function(r){
url += r.test(url) ? '/' + window.content.location.pathname.split('/')[1] : '';
});
liberator.open(
'http://www.google.com/search?q=' +
encodeURIComponent(args.literalArg) +
'+site%3A' +
url,
liberator.NEW_TAB
);
},
{
completer: function (context) completion.url(context, 'S'),
literal: 0,
},
true
);
EOM
" Tab pinned. http://qiita.com/t3kot3ko/items/1b032940dbb79e88323e"{{{2
javascript <<EOM
liberator.modules.commands.addUserCommand(["togglepin"], "add pin to current tab",
function() {
var currentTab = gBrowser.mCurrentTab
if (currentTab.pinned) {
gBrowser.unpinTab(currentTab)
} else {
gBrowser.pinTab(currentTab)
}
});
EOM
nnoremap @ :togglepin<CR>
" FORCE <ESC> for the INSERT MODE; when focus WYSIWYG editor, not transmit NORMAL MODE by default <ESC> behavior. {{{2
js <<EOS
liberator.modules.mappings.addUserMap(
[modes.INSERT],
["<ESC>", "<C-[>"],
"Focus content",
function() {
while(liberator.mode == modes.INSERT) {
liberator.modules.events.onEscape();
}
}
);
EOS
" firefox about:config {{{1
" don't show download-manager
set! browser.download.manager.showWhenStarting=false
" feedly
set! browser.contentHandlers.types.6.title=feedly
set! browser.contentHandlers.types.6.type=application/vnd.mozilla.maybe.feed
set! browser.contentHandlers.types.6.uri=http://cloud.feedly.com/#subscription/feed/%s
" vimppm {{{1
js <<EOM
if (liberator.has("MacUnix")) {
// Mac
liberator.execute("source ~/.vimperator/vimppm/plugin/vimppm.js");
} else {
// Other
liberator.execute("source ~/vimperator/vimppm/plugin/vimppm.js");
}
EOM
" vimppm '_libly.js'
" vimppm 'feedSomeKeys_3.js'
" vimppm 'x-hint.js'
vimppm '_smooziee.js'
vimppm 'copy.js'
vimppm 'caret-hint.js'
vimppm 'commandBookmarklet.js'
" vimppm 'google-exopen.js'
" vimppm 'opener-ex.js'
" _smooziee {{{
let g:smooziee_scroll_amount="150"
let g:smooziee_scroll_interval="50"
"}}}
" copy {{{
js <<EOM
// util functions {{{
function getDocTitle() { return buffer.title; }
function getDocUrl() { return buffer.URL; }
function getDocSelection() {
var selection = content.window.getSelection();
var res = '';
for(var i = 0; i < selection.rangeCount; ++i) {
res += selection.getRangeAt(i).toString();
}
return res;
}
function getDocSelectionHtml() {
var selection = content.window.getSelection();
var res = '';
var serializer = new XMLSerializer();
var hasInlines = false;
for(var i = 0; i < selection.rangeCount; ++i) {
var contents = selection.getRangeAt(i).cloneContents();
Array.prototype.forEach.call(contents.childNodes, function(node) {
switch(node.nodeType) {
case Node.ELEMENT_NODE:
var displayStyle = node.style.display;
hasInlines &= (displayStyle != 'block');
// Delete INTERRUPTION attributes.
node.removeAttribute('class');
node.removeAttribute('id');
node.removeAttribute('target');
//node.removeAttribute('name');
node.removeAttribute('style');
node.removeAttribute('tabstop');
break;
case Node.TEXT_NODE:
hasInlines &= 0;
break;
}
});
res += serializer.serializeToString(contents);
}
return res
.replace(/<(\/)?(\w+)([\s\S]*?)>/g, function(all, close, tag, attr) {
return "<" + close + tag.toLowerCase() + attr + ">";
})
// Delete a INTERRUPTION XML-namespace attribute.
// XML-namespace attribute can not remove by DOM method (maybe, I not know).
.replace(/(?!<\w+(\s*[^= ]+="[^"]*")*)\s+xmlns="[^"]*"/, '');
}
function escape4Html(str) {
// SPACE character convert to "m"-width space,
// because " " meaning "Non-Breaking".
// I not want to inhibit breaking.
return str
.replace('&','&')
.replace('<','<')
.replace('>','>')
.replace(' ', '  '); // [FIXME] Ignore ONE space.
// Ah... Are their enough escape handling?
}
// }}}
liberator.globalVariables.copy_templates = [
// HTML/XHTML
{ label: 'title', value: '%TITLE%' },
{ label: 'url', value: '%URL%' },
{ label: 'tu', value: '%TITLE% %URL%' },
{ label: 'anchor', value: '<a href="%URL%">%TITLE%</a>',
custom: function() {
return '<a href="' + getDocUrl() + '">'
+ escape4Html(getDocTitle()) + '</a>';
}
},
{ label: 'selanchor', value: '<a href="%URL%" title="%TITLE%">%SEL%</a>',
custom: function() {
return '<a href="' + getDocUrl()
+ '" title="' + escape4Html(getDocTitle()) + '">'
+ escape4Html(getDocSelection()) + '</a>';
}
},
{ label: 'bq', value: '<blockquote cite="%URL%" title="%TITLE%">%HTMLSEL%</blockquote>',
custom: function() {
/* [FIXME]
* If getDocSelectionHtml() returned value has inline-elements at the outermost, must rapped block-element.
* If inlines & blocks mixed, rapped <div>, else if inlines only, rapped <p>.
*/
return '<blockquote cite="' + getDocUrl()
+ '" title="' + getDocTitle() + '">'
+ getDocSelectionHtml() + '</blockquote>';
}
},
{ label: 'bq1', value: '<blockquote> with <a>.',
custom: function() {
return plugins.exCopy.get('bp').custom()
+ '\n<p>以上、<cite>'
+ plugins.exCopy.get('anchor').custom()
+ '</cite>より。</p>';
}
},
{ label: 'q', value: '<q cite="%URL%" title="%TITLE%">%HTMLSEL%</q>',
custom: function() {
return '<q cite="' + getDocUrl()
+ '" title="' + getDocTitle() + '">'
+ escape4Html(getDocSelection()) + '</q>';
}
},
// Markdown
{ label: 'mdanchor', value: '[%TITLE%](%URL%)' },
{ label: 'mdselanchor', value: '[%SEL%](%URL% %TITLE%)' },
{ label: 'mkbq', value: 'Markdown style QUOTE',
custom: function() {
return getDocSelection().split("\n").map(function(line) {
return '> ' + line;
}).join("\n");
}
},
// reST
{ label: 'rest', value: 'reST style',
custom: function() {
return '`' + getDocTitle() + ' <' +
getDocUrl() + '>`_'
}
},
// Textile
{ label: 'tanchor', value: '"%TITLE%":%URL%' },
{ label: 'tbq', value: 'Textile style QUOTE',
custom: function() {
const mark = "bq. ";
const space = (function() {
var res = "", len = mark.length, i;
for(i = 0; i < len; ++i) { res += " "; }
})();
var lines = getDocSelection().split("\n"), i;
lines[0] = mark + lines[0];
for(i = 1; i < lines.length; ++i) {
lines[i] = space + lines[i];
}
return lines.join("\n");
}
},
// Hatena
{ label: 'hanchor', value: '[%URL%:title=]' },
{ label: 'hselanchor', value: '[%URL%:title=%SEL%]' },
{ label: 'hbq', value: '>>\n%SEL%\n<<' },
{ label: 'hbq1', value: '>>\n%SEL%\n<<\n[%URL%:title=]' },
// tinyurl
{ label: 'tinyurl', value: 'Get Tiny URL',
custom: function() {
return util.httpGet('http://tinyurl.com/api-create.php?url=' + encodeURIComponent(buffer.URL))
.responseText;
}
},
// 自blog用Twitterログ記述HTML
// <table class="twitter-log"> ~ </table>で囲む事
// using Twitter Images ( http://twitterimag.es )
{ label: 'twlog', value: 'Twitter log',
custom: function() {
if(buffer.URL.search(/^https?:\/\/twitter\.com\//) == -1) {
liberator.echoerr('This site is not Twitter.');
return;
}
const tweetId = buffer.URL.match(/status\/(\d+)/)[1];
return io.system('ruby ~/gettweet.rb ' + tweetId);
}
},
// NeoBundle.vim syntax
{ label: 'neobundle', value: "NeoBundle '%TITLE%'",
custom: function() {
if(!getDocUrl().match('^https?://github\.com/')) {
throw "This page is not GitHub!!!";
}
return getDocTitle();
}
},
];
EOM
nnoremap C :copy<space>
vnoremap C :copy<space>
" vim: ft=vim sw=2 sts=2 fdm=marker