external-completion-3
コードがかなり見苦しくなってきた……
変更点
既知の問題
候補をクリックしたときの動作を変更できていない
dependencies
code: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,
}));
}