generated at
external-completion-3
コードがかなり見苦しくなってきた……

基本的には/programming-notes/external-completion-3のコードと同じ
変更点
キーボード操作をScrapBindingsで設定するようにした
external-completion-for-personalの機能を追加した
emoji-completionの機能を正しく動かせるようにした

既知の問題
候補をクリックしたときの動作を変更できていない

dependencies
script.js
import {ExternalCompletion} from '../external-completion-3%2Fcore/script.js'; import {setting} from '../external-completion-3%2Fsource/script.js'; import {scrapBindings} from '../ScrapBindings/script.js'; export async function external(projects) { const completion = new ExternalCompletion(); // 好きなショートカットキー登録方法を使う await scrapBindings.install(); const exec = (command) => { if (!completion.completing) return true; command(); return false; }; scrapBindings.push( {key: 'shift+tab', command: () => exec(() => completion.selectPrev()),}, {key: 'tab', command: () => exec(() => completion.selectNext()),}, {key: 'ctrl+space', command: () => exec(() => completion.start()),}, {key: 'enter', command: () => exec(() => completion.confirm()),}, {key: 'ctrl+i', command: () => exec(() => completion.confirm({mode: 'icon'})),}, ); // 補完ソースを選ぶ completion.push(setting(projects)); } export async function bare(projects) { const completion = new ExternalCompletion(); // ショートカットキーは登録しない // 補完ソースを選ぶ completion.push(setting(projects, {trigger: /^\[(?:\]|[^:\/]+)/, makeRaw: text => text.slice(1, -1)})); } export async function icon(projects) { const completion = new ExternalCompletion(); await scrapBindings.install(); const exec = (command) => { if (!completion.completing) return true; command(); return false; }; scrapBindings.push( {key: 'shift+tab', command: () => exec(() => completion.selectPrev()),}, {key: 'tab', command: () => exec(() => completion.selectNext()),}, {key: 'ctrl+space', command: () => exec(() => completion.start()),}, {key: ['ctrl+i', 'enter'], command: () => exec(() => completion.confirm({mode: 'icon'})),}, ); // 補完ソースを選ぶ completion.push(setting(projects, { trigger: /^\[:/, icon: true, limit: 10, verbose: true, })); }

#2021-04-09 17:33:02
#2021-04-08 17:55:38