Skip to content

Commit

Permalink
refactor: move up the bindings to nvim
Browse files Browse the repository at this point in the history
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
  • Loading branch information
kiprasmel committed May 8, 2022
1 parent b47831a commit 6f58047
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions nvim-git-rebase-todo/nvim-git-rebase-todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const execAsync = util.promisify(cp.exec);
*/

export default function nvimGitRebaseTodo(plugin: NvimPlugin): void {
const { nvim: vim } = plugin;

plugin.setOptions({ dev: false });

/**
* TODO make actually configurable
*/
Expand All @@ -38,6 +34,66 @@ export default function nvimGitRebaseTodo(plugin: NvimPlugin): void {
rowLowerIfCloseToLeft: 0,
};

/**
*
*/

const { nvim: vim } = plugin;

plugin.setOptions({ dev: false });

const pattern = "git-rebase-todo" as const;
const commonOptions: AutocmdOptions = {
sync: false, //
pattern,
eval: 'expand("<afile>")', // i don't know what this does
};

/**
* :help events
*/
plugin.registerAutocmd(
"BufEnter", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);

plugin.registerAutocmd(
"BufLeave", //
() => hideWindow(),
{
...commonOptions,
}
);

plugin.registerAutocmd(
"CursorMoved", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);

/**
* only needed when you create a new line,
* otherwise could get rid...
*
* TODO OPTIMIZE
*/
plugin.registerAutocmd(
"CursorMovedI", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);

/**
*
*/

let gBuffer: Buffer;
let gWindow: Window;

Expand Down Expand Up @@ -398,56 +454,4 @@ export default function nvimGitRebaseTodo(plugin: NvimPlugin): void {
height,
});
};

/**
*
*/

const pattern = "git-rebase-todo" as const;
const commonOptions: AutocmdOptions = {
sync: false, //
pattern,
eval: 'expand("<afile>")', // i don't know what this does
};

/**
* :help events
*/
plugin.registerAutocmd(
"BufEnter", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);

plugin.registerAutocmd(
"BufLeave", //
() => hideWindow(),
{
...commonOptions,
}
);

plugin.registerAutocmd(
"CursorMoved", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);

/**
* only needed when you create a new line,
* otherwise could get rid...
*
* TODO OPTIMIZE
*/
plugin.registerAutocmd(
"CursorMovedI", //
() => drawLinesOfCommittishStat(),
{
...commonOptions,
}
);
}

0 comments on commit 6f58047

Please sign in to comment.