Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chores #34

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions denops/aider/bufferOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export async function exitAiderBuffer(denops: Denops): Promise<void> {

/**
* Opens an Aider buffer.
* If an Aider buffer is already open, it opens that buffer.
* If no Aider buffer is open, it creates a new buffer and opens it.
* If an Aider buffer is already alive, it opens that buffer.
* If no Aider buffer is alive, it creates a new buffer and opens it.
* The way the buffer is opened depends on the value of openBufferType.
* If openBufferType is "split" or "vsplit", the buffer is opened in a split.
* Otherwise, the buffer is opened in a floating window.
Expand Down Expand Up @@ -247,8 +247,8 @@ export async function openSplitWindow(denops: Denops): Promise<void> {
async function openFloatingWindow(denops: Denops, bufnr: number): Promise<void> {
const terminal_width = Math.floor(ensure(await n.nvim_get_option(denops, "columns"), is.Number));
const terminal_height = Math.floor(ensure(await n.nvim_get_option(denops, "lines"), is.Number));
const floatWinHeight = ensure(await v.g.get(denops, "aider_floatwin_height"), is.Number);
const floatWinWidth = ensure(await v.g.get(denops, "aider_floatwin_width"), is.Number);
const floatWinHeight = maybe(await v.g.get(denops, "aider_floatwin_height"), is.Number) || 20;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。
最近floatingしか使ってないので、ここらへんがおそろかに…。

const floatWinWidth = maybe(await v.g.get(denops, "aider_floatwin_width"), is.Number) || 100;

const row = Math.floor((terminal_height - floatWinHeight) / 2);
const col = Math.floor((terminal_width - floatWinWidth) / 2);
Expand Down
23 changes: 5 additions & 18 deletions denops/aider/utils.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import * as fn from "https://deno.land/x/[email protected]/function/mod.ts";
import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as v from "https://deno.land/x/[email protected]/variable/mod.ts";
import {
ensure,
is,
maybe,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, is, maybe } from "https://deno.land/x/[email protected]/mod.ts";

/**
* Gets the additional prompt from vim global variable "aider_additional_prompt".
* Gets the additional prompt from vim global variable
*
* @param {Denops} denops - The Denops instance.
* @returns {Promise<string[] | undefined>} A promise that resolves to an array of additional prompts, or undefined if no prompts are found.
*/
export async function getPromptFromVimVariable(
denops: Denops,
variableName: string,
): Promise<string[] | undefined> {
const prompts = maybe(
await v.g.get(denops, variableName),
is.ArrayOf(is.String),
);
export async function getPromptFromVimVariable(denops: Denops, variableName: string): Promise<string[] | undefined> {
const prompts = maybe(await v.g.get(denops, variableName), is.ArrayOf(is.String));
return Array.isArray(prompts) ? prompts : undefined;
}

Expand All @@ -41,10 +31,7 @@ export async function getCurrentFilePath(denops: Denops): Promise<string> {
* @returns {Promise<string>} A promise that resolves to the buffer name.
* @throws {Error} Throws an error if the buffer name is not a string.
*/
export async function getBufferName(
denops: Denops,
bufnr: number,
): Promise<string> {
export async function getBufferName(denops: Denops, bufnr: number): Promise<string> {
const bufname = await fn.bufname(denops, bufnr);
return ensure(bufname, is.String);
}