Skip to content

Commit

Permalink
parallelise calls to nvim gRPC api where possible
Browse files Browse the repository at this point in the history
idk if this is actually faster or not, gotta test it out

Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
  • Loading branch information
kiprasmel committed May 8, 2022
1 parent 8e2c72d commit 67cbe2e
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions nvim-git-rebase-todo/nvim-git-rebase-todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ export default function nvimGitRebaseTodo(plugin: NvimPlugin): void {
width, //
height,
}: SetWindowRelativeToCursorOpts): Promise<OpenWindowOptions> => {
const cursor = await vim.window.cursor;

const relWin = await vim.window;
const col: number = config.closeToLeft || (await relWin.width);
const [relWin, cursor, col] = await Promise.all([
vim.window,
vim.window.cursor,
config.closeToLeft || vim.window.width,
]);

return {
// relative: "cursor",
Expand Down Expand Up @@ -195,26 +196,35 @@ export default function nvimGitRebaseTodo(plugin: NvimPlugin): void {
* instead of taking it in as param
*/

const relWin: Window = await vim.getWindow();
const col: number = config.closeToLeft || (await relWin.width);

const opts: OpenWindowOptions = config.relativeToCursor
? {
...(await getRelativeWindowOptions({ width, height })),
}
: ({
relative: "win",
win: relWin.id,
//
width,
height,
//
// anchor: "NE", // TODO is this needed?
row: 0 + (config.closeToLeft ? config.rowLowerIfCloseToLeft : 0),
col,
//
style: "minimal",
} as const);
let relWin: Window;
let col: number;
let opts: OpenWindowOptions;

if (config.relativeToCursor) {
[relWin, col, opts] = await Promise.all([
vim.window, //
vim.window.width,
getRelativeWindowOptions({ width, height }),
]);
} else {
[relWin, col] = await Promise.all([
vim.window, //
vim.window.width,
]);
opts = {
relative: "win",
win: relWin.id,
//
width,
height,
//
// anchor: "NE", // TODO is this needed?
row: 0 + (config.closeToLeft ? config.rowLowerIfCloseToLeft : 0),
col,
//
style: "minimal",
};
}

const enter = false;
const window: number | Window = await vim.openWindow(buffer, enter, opts);
Expand Down

0 comments on commit 67cbe2e

Please sign in to comment.