Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tennashi/deno-denops-app


https://github.com/tennashi/deno-denops-app

Last synced: 22 days ago
JSON representation

Awesome Lists containing this project

README

        

# WIP: denops_app

UI module for [denops.vim](https://github.com/vim-denops/denops.vim).

```typescript
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
Buffer,
DenopsApp,
ListWidget,
PathParams,
Route,
TextWidget,
} from "https://deno.land/x/[email protected]/mod.ts";

const items = [
{ id: 1, hoge: "hoge" },
{ id: 2, hoge: "hogehoge" },
{ id: 3, hoge: "hogehogehoge" },
];

const listHoge = (_params: PathParams): Promise => {
const list = new ListWidget<{ id: number; hoge: string }>();
items.forEach((item) => {
list.setItem(
item,
(item: { id: number; hoge: string }): string => item.hoge,
);
});

list.handleKey(
"",
async (denops: Denops, item: { id: number; hoge: string }) => {
await denops.cmd(`bd! | new denopsapp://${denops.name}/hoge/${item.id}`);
},
);

return Promise.resolve(list);
};

const detailHoge = (params: PathParams): Promise => {
const text = new TextWidget();

text.setContent(`Hoge: ${items[Number(params.id) - 1].hoge}`);

return Promise.resolve(text);
};

export async function main(denops: Denops): Promise {
const app = new DenopsApp(denops);

const routes: Route[] = [
{ path: "/hoge", component: listHoge },
{ path: "/hoge/:id", component: detailHoge },
];

app.setRoutes(routes);
app.addCommand("DenopsAppAwesomeListHoge", "/hoge");

await app.initialize();
}
```