From 9f39a067d6126ad69de154ae48a836012723080a Mon Sep 17 00:00:00 2001 From: Kota Kato Date: Wed, 24 Nov 2021 21:53:09 +0900 Subject: [PATCH] format --- README.md | 1 + denops/bufpreview/@renderer/markdown/main.ts | 10 +++++----- denops/bufpreview/lib/server.ts | 16 ++++++++-------- denops/bufpreview/lib/types.ts | 10 +++++----- denops/bufpreview/main.ts | 17 ++++++++++++++--- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 10e0040..dc00ede 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Commands: ``` Open preview window automatically: + ```vim augroup bufpreview autocmd! diff --git a/denops/bufpreview/@renderer/markdown/main.ts b/denops/bufpreview/@renderer/markdown/main.ts index 2563169..9f58345 100644 --- a/denops/bufpreview/@renderer/markdown/main.ts +++ b/denops/bufpreview/@renderer/markdown/main.ts @@ -1,8 +1,8 @@ -import { Denops, Renderer, op } from "../../lib/deps.ts"; +import { Denops, op, Renderer } from "../../lib/deps.ts"; export default class Markdown extends Renderer { constructor(denops: Denops) { - super(denops) + super(denops); } get rendererClientHTML() { @@ -12,12 +12,12 @@ export default class Markdown extends Renderer { } async avaiableRenderer() { - const ret = (await op.filetype.get(this._denops)) == "markdown" - return ret + const ret = (await op.filetype.get(this._denops)) == "markdown"; + return ret; } data() { - return {} + return {}; } dataFromClient(_) {} diff --git a/denops/bufpreview/lib/server.ts b/denops/bufpreview/lib/server.ts index 04f24e9..8102801 100644 --- a/denops/bufpreview/lib/server.ts +++ b/denops/bufpreview/lib/server.ts @@ -8,7 +8,7 @@ export default class Server { private _denops: Denops; private _bufnr: number; private _onClose: () => void; - private _renderer: Renderer + private _renderer: Renderer; private _buffer: Buffer; private _listener: Deno.Listener | undefined; @@ -25,15 +25,15 @@ export default class Server { // サーバ側で通信が切断された時に呼ばれます onClose: () => void, // レンダラー - renderer: Renderer + renderer: Renderer, ) { this._denops = denops; this._bufnr = bufnr; this._onClose = onClose; - this._renderer = renderer + this._renderer = renderer; // TODO: 消す - this._renderer.avaiableRenderer() + this._renderer.avaiableRenderer(); this._buffer = new Buffer(denops, this._bufnr); @@ -53,7 +53,7 @@ export default class Server { cursorLine: { linePos: buffer.cursorline, bufLengh: buffer.lines.length, - data: this._renderer.data("cursorMoved") + data: this._renderer.data("cursorMoved"), }, }; this._sockets.forEach((socket) => { @@ -64,13 +64,13 @@ export default class Server { // バッファが削除された時 this._buffer.events.on("bufDelete", (_) => { const data = { - data: this._renderer.data("bufDelete") - } + data: this._renderer.data("bufDelete"), + }; this.close(); }); // クライアント - this._body = this._renderer.rendererClientHTML + this._body = this._renderer.rendererClientHTML; } run(host: string, port: number) { diff --git a/denops/bufpreview/lib/types.ts b/denops/bufpreview/lib/types.ts index e6ff6c5..43b5838 100644 --- a/denops/bufpreview/lib/types.ts +++ b/denops/bufpreview/lib/types.ts @@ -1,4 +1,4 @@ -import { Denops } from "./deps.ts" +import { Denops } from "./deps.ts"; type JsonPrimitive = | boolean @@ -15,15 +15,15 @@ type Json = JsonPrimitive | JsonArray | JsonObject; type Autocmd = | "textChenged" | "cursorMoved" - | "bufDelete" + | "bufDelete"; // レンダラー // denopsが渡される export abstract class Renderer { - private _denops + private _denops; - constructor (denops: Denops) { - this._denops = denops + constructor(denops: Denops) { + this._denops = denops; } // クライアントのHTML abstract get rendererClientHTML(): string; diff --git a/denops/bufpreview/main.ts b/denops/bufpreview/main.ts index d6aa181..13d5765 100644 --- a/denops/bufpreview/main.ts +++ b/denops/bufpreview/main.ts @@ -1,11 +1,22 @@ -import { Denops, ensureString, fn, op, open, vars, Renderer } from "./lib/deps.ts"; +import { + Denops, + ensureString, + fn, + op, + open, + Renderer, + vars, +} from "./lib/deps.ts"; import Server from "./lib/server.ts"; // 一度に開けるサーバーは一つ let server: Server | undefined; -const Markdown = (await import((new URL("./@renderer/markdown/main.ts", import.meta.url)).href)).default +const Markdown = + (await import( + (new URL("./@renderer/markdown/main.ts", import.meta.url)).href + )).default; export function main(denops: Denops) { denops.dispatcher = { @@ -30,7 +41,7 @@ export function main(denops: Denops) { // サーバーを開く const openServer = async () => { // レンダラー - const renderer = new Markdown(denops) + const renderer = new Markdown(denops); // サーバーが既に開かれているなら if (server != undefined) { server.close();