From 6f580476feb05b29747ebde626ef2c4b8c54caf7 Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Sat, 9 Apr 2022 02:53:01 +0300 Subject: [PATCH] refactor: move up the bindings to nvim Signed-off-by: Kipras Melnikovas --- nvim-git-rebase-todo/nvim-git-rebase-todo.ts | 116 ++++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/nvim-git-rebase-todo/nvim-git-rebase-todo.ts b/nvim-git-rebase-todo/nvim-git-rebase-todo.ts index b9f1700c..e6c458e6 100644 --- a/nvim-git-rebase-todo/nvim-git-rebase-todo.ts +++ b/nvim-git-rebase-todo/nvim-git-rebase-todo.ts @@ -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 */ @@ -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("")', // 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; @@ -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("")', // 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, - } - ); }