v6.0.0
Development ddc.vim helpers that allow you to paste word-kind sources gathering unprintable characters.
Attributes
Includes Deno configuration
Repository
Current version released
6 months ago
ddc-unprintable
ddc-unprintable is helper library for ddc.vim sources in Denops. This module contains helpers that allow you to paste word-kind sources gathering unprintable characters.
Usage
- Instantiate
Unprintableclass in your ddc source. - Call
onInit()in yourSource.onInit()method to initialize instance. - Call
convertItems()in yourSource.gather()method to process completion items. - Call
onCompleteDone()in yourSource.onCompleteDone()method to restore the original text.
Example of using this module in your source:
import { Unprintable, UnprintableUserData } from "jsr:@milly/ddc-unprintable";
import {
BaseSource,
type GatherArguments,
type OnCompleteDoneArguments,
type OnInitArguments,
} from "jsr:@shougo/ddc-vim/source";
import type { Item } from "jsr:@shougo/ddc-vim/types";
interface MyParams extends Record<string, unknown> {
// Add your source parameters here
}
interface MyUserData extends UnprintableUserData {
// Add your user data properties here
}
type MyItem = Item<MyUserData>;
export class Source extends BaseSource<MyParams, MyUserData> {
// 1. Instantiate this class.
#unprintable = new Unprintable<MyUserData>();
override params(): MyParams {
return {};
}
override async onInit(args: OnInitArguments<MyParams>): Promise<void> {
// 2. Call `onInit()`.
await this.#unprintable.onInit(args);
}
override async gather(
args: GatherArguments<MyParams>,
): Promise<MyItem[]> {
const myItems: MyItem[] = [
// Generate your items here.
];
// 3. Call `convertItems()`.
const convertedItems = await this.#unprintable!.convertItems(
args.denops,
myItems,
args.context.nextInput,
);
return convertedItems;
}
override async onCompleteDone(
args: OnCompleteDoneArguments<MyParams, MyUserData>,
): Promise<void> {
// 4. Call `onCompleteDone()`.
await this.#unprintable.onCompleteDone(args);
}
}License
This project is licensed under the MIT License. See the LICENSE file for details.