vimperator

晒し第三弾。まず vimperatorrc 。いい加減 autoIgnoreKey.js から feedSomeKeys.js へ switch すべきと思ってるんだけど google reader の存在とかやる気の問題とかで長らくそのままになっている。あとはニコニコ動画関連の map が長い。長すぎる。

" for 1.2pre (created: 2008/05/03 07:30:09)

" Basics ------------------------------------------------------------------
" タイトルバーのブラウザ表示名を変更
set titlestring=Firefox with Vimperator

" 検索キーワードのハイライト
set hlsearch

" デフォルト検索エンジンは google
set defsearch=google

" :[tab]open での補完順位をブックマーク・検索エンジンの suggest ・履歴の順にする
set complete=blS

" 新しいタブを開いてもフォーカスしない
set activate=

" ]] に反応するキーワードに"次"を追加
set nextpattern+=次
" [[ に反応するキーワードに"前"を追加
set previouspattern+=前

" Ctrl + d / u でスクロールする幅を 3 行分に変更
set scroll=3

" ヒントモードの絞り込みに XUL/Migemo を使う
set hintmatching=custom

" 以下のコマンド結果を新しいタブで開く
" addons + downloads + help + javascript + prefs
set newtab=all

" 補完候補を表示する
set wildoptions=auto


" Mappings ----------------------------------------------------------------
" Ctrl + h / l で左右のタブにフォーカス
map <C-h> gT
map <C-l> gt

" Ctrl + p / n でタブを左右に移動
" map <C-p> :tabmove! -1<CR>
" map <C-n> :tabmove! +1<CR>

" <S-a> ( デフォルト ) で bookmark toggle を解除
map <S-a> <Nop>

" <C-k> で検索ページにいくのがウザイので無効化
map <C-k> <Nop>

" Windows のキーバインドを通す
noremap <C-a> <C-v><C-a>
noremap <C-c> <C-v><C-c>
noremap <C-s> <C-v><C-s>

inoremap <C-a> <C-v><C-a>
inoremap <C-c> <C-v><C-c>
inoremap <C-s> <C-v><C-s>
inoremap <C-x> <C-v><C-x>
inoremap <C-v> <C-v><C-v>
inoremap <C-z> <C-v><C-z>
inoremap <C-y> <C-v><C-y>

cnoremap <C-a> <C-v><C-a>
cnoremap <C-c> <C-v><C-c>
cnoremap <C-s> <C-v><C-s>
cnoremap <C-x> <C-v><C-x>
cnoremap <C-v> <C-v><C-v>
cnoremap <C-z> <C-v><C-z>
cnoremap <C-y> <C-v><C-y>

" <C-a> / <C-x> を <C-w> / <C-e> に退避
noremap <C-w> <C-a>
noremap <C-e> <C-x>

" XUL/Migemo 用無理やり map
map <C-f> <C-v>/gi

" フルスクリーン化用 F11 をそのまま通す
noremap <F11> <C-v><F11>


" Plugins -----------------------------------------------------------------
" a で del.icio.us へ post
" plugin : direct_bookmark.js
"map a :sbm<Space>

" v でブックマークコメントを表示
" plugin : sbmcommentsviewer.js
"map v :viewSBMComments -t hd

" c で title 要素コピー
" plugin : copy.js
"map c :copy %TITLE%<CR>

" e で ALC 英辞郎で辞書を引く
" plugin : lookupDictionary.js
"map e :eijiro<Space>

" 使用する Social Bookmark を del.icio.us とはてなブックマークに設定
" plugin : direct_bookmark.js
let g:direct_sbm_use_services_by_post='dh'
let g:direct_sbm_use_services_by_tag='dh'

" サービス名を「またニコ」にする
" plugin : matanico.js
let g:matanico_status_servicename='またニコ'
let g:matanico_status_format='$SERVICENAME : $COMMENT [$SUBJECT]($PLAYTIME) - $URL'
let g:matanico_tag_servicename='またニコタグ'
let g:matanico_tag_format='$SERVICENAME : $COMMENT [$TAG]($NUMOFVIDEOS件) - $URL'

" 再生リストの表示数を 7 個に
" plugin : nnp_cooperation.js
let g:nnp_coop_numoflist='7'

" 自動で PASS THROUGH mode にする URL の設定
" plugin : autoIgnoreKey.js
javascript <<EOM
    liberator.globalVariables.autoignorekey_pages = uneval([
        /^https?:\/\/www\.google\.com\/reader\//,
        /^http:\/\/www\.rememberthemilk\.com\/home\//,
        /^http:\/\/b\.hatena\.ne\.jp\/[^(help)]+/,
    ]);
EOM


" Others ------------------------------------------------------------------
" ニコニコ動画の操作用 map
" plugin : nnp_cooperation.js
" plugin : nicontroller.js
javascript <<EOM
liberator.plugins.nicomap = function() {
/*
        template
        {
            command:        '',
            action:         function() {},
            description:    '',
            extra:          {},
        },
*/
    // stuff functions
    function registMaps(maps) {
        for (let i=0 ; i<maps.length ; ++i) {
            liberator.mappings.addUserMap(
                [liberator.modes.NORMAL],
                [maps[i].command],
                maps[i].description,
                maps[i].action,
                maps[i].extra
            );
        }
        return true;
    }
    function removeMaps(maps) {
        for (let i=0 ; i<maps.length ; ++i) {
            liberator.mappings.remove(liberator.modes.NORMAL, maps[i].command);
        }
        return true;
    }

    // URL applied maps
    const specialURL = '^http://www\.nicovideo\.jp/(watch|ranking|mylist)';

    // map definitions
    const defMaps = [
        {
            command:        'a',
            action:         function() { liberator.execute('normal :sbm<Space>'); },
            description:    'ready social bookmark command',
            extra:          { rhs: ':sbm<Space>', },
        },
        {
            command:        'v',
            action:         function() { liberator.execute('viewSBMComments -t hd'); },
            description:    'display social bookmark comments',
            extra:          { rhs: ':viewSBMComments -t hd<CR>', },
        },
    ];
    const nicoMaps = [
        {
            command:        'a',
            action:         function() { liberator.execute('nnppushallvideos'); },
            description:    'push all video in current tab to NicoNicoPlaylist',
            extra:          { rhs: ':nnppushallvideos<CR>', },
        },
        {
            command:        'q',
            action:         function() { liberator.execute('nnpclear'); },
            description:    'clear NicoNicoPlaylist buffers',
            extra:          { rhs: ':nnpclear<CR>', },
        },
        {
            command:        'l',
            action:         function() { liberator.execute('nnpgetlist'); },
            description:    'display NicoNicoPlaylist',
            extra:          { rhs: ':nnpgetlist<CR>', },
        },
        {
            command:        'i',
            action:         function() { liberator.execute('nicoinfo') },
            description:    'display "nicontroller.js" information',
            extra:          { rhs: ':nicoinfo<CR>', },
        },
        {
            command:        'p',
            action:         function() { liberator.execute('nicopause'); },
            description:    'toggle pause / play current tab\'s video',
            extra:          { rhs: ':nicopause<CR>', },
        },
        {
            command:        'm',
            action:         function() { liberator.execute('nicomute'); },
            description:    'toggle mute current tab\'s video',
            extra:          { rhs: ':nicomute<CR>', },
        },
        {
            command:        'v',
            action:         function() { liberator.execute('nicommentvisible'); },
            description:    'toggle comment visible current tab\'s video',
            extra:          { rhs: ':nicommentvisible<CR>', },
        },
        {
            command:        'z',
            action:         function() { liberator.execute('nicosize'); },
            description:    'toggle normal / fit-window size current tab\'s video',
            extra:          { rhs: ':nicosize<CR>', },
        },
        {
            command:        's',
            action:         function() { liberator.execute('nicoseek'); },
            description:    'seek to start current tab\'s video',
            extra:          { rhs: ':nicoseek<CR>', },
        },
        {
            // [N]n
            // N 番目の動画を再生する。
            // 指定なしの場合次の動画が再生される。
            command:        'n',
            action:         function(count) {
                if(count === -1) count = 1;
                liberator.execute(':nnpplaynext ' + count);
            },
            description:    'play next item in NicoNicoPlaylist',
            extra:          { flags:  liberator.Mappings.flags.COUNT },
        },
        {
            // [N]w
            // 上から N 個の動画を削除する。
            // 指定なしの場合一番上の動画が削除される。
            command:        'w',
            action:         function(count) {
                if(count === -1) count = 1;
                for(let i=0 ; i<count ; ++i) liberator.execute(':nnpremove');
                liberator.execute(':nnpgetlist');
            },
            description:    'remove item in NicoNicoPlaylist',
            extra:          { flags:  liberator.Mappings.flags.COUNT },
        },
        {
            // [N]-
            // N 秒前にシークする。
            // 指定なしの場合 10 秒前。
            command:        '-',
            action:         function(count) {
                if(count === -1) count = 10;
                liberator.execute(':nicoseek! ' + '-' + count);
            },
            description:    'seek by count backward',
            extra:          { flags:  liberator.Mappings.flags.COUNT },
        },
        {
            // [N]+
            // N 秒後にシークする。
            // 指定なしの場合 10 秒後。
            command:        '+',
            action:         function(count) {
                if(count === -1) count = 10;
                liberator.execute(':nicoseek! ' + count);
            },
            description:    'seek by count forward',
            extra:          { flags:  liberator.Mappings.flags.COUNT },
        },
    ];

    // main
    if(buffer.URL.match(specialURL)) {
        removeMaps(defMaps);
        registMaps(nicoMaps);
    }
    else {
        removeMaps(nicoMaps);
        registMaps(defMaps);
    }
};

liberator.autocommands.add('LocationChange', '.*', 'js liberator.plugins.nicomap()');
EOM

" wildoptions=auto のチラチラ対策
javascript <<EOM
[
    ['<C-p>',   ':tabmove! -1',             'move to tab left'],
    ['<C-n>',   ':tabmove! +1',             'move to tab right'],
    ['c',       ':copy title',              'copy title on current tab'],
    ['e',       'normal :eijiro<Space>',    'ready eijiro command'],
].forEach(
    function([key, command, description]){
        liberator.mappings.addUserMap(
            [liberator.modes.NORMAL],
            [key],
            description,
            function () { liberator.execute(command); },
            { rhs: key, }
        );
    }
);
EOM


" vim: ft=vimperator sw=4 sts=4

使ってる plugins 。これで十分快適。

  • autoIgnoreKey.js
  • copy.js
  • direct_bookmark.js
  • feeding_greader.js
  • gmperator.js
  • ldrize_cooperation.js
  • ldrize_cooperation_fetch_flv.js
  • lookupDictionary.js
  • matanico.js
  • migemo_hint.js
  • nicontroller.js
  • nnp_cooperation.js
  • sbmcommentsviewer.js