Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tennashi/deno-denops-app
https://github.com/tennashi/deno-denops-app
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tennashi/deno-denops-app
- Owner: tennashi
- License: mit
- Created: 2021-07-02T14:31:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-17T06:20:14.000Z (over 3 years ago)
- Last Synced: 2023-08-08T20:48:09.704Z (over 1 year ago)
- Language: TypeScript
- Size: 15.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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();
}
```