From ea80826fd256485c2a1941fec5b5ba4c8361bc41 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 5 Jun 2021 14:24:17 -0400 Subject: [PATCH] gt/gT = add goto Nth tab behavior As it does in vim. --- modules/editor/evil/config.el | 4 ++-- modules/ui/tabs/autoload.el | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 modules/ui/tabs/autoload.el diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index f9dcd1fa1..33c0f37d3 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -447,8 +447,8 @@ directives. By default, this only recognizes C directives.") :n "]w" #'+workspace/switch-right :n "[w" #'+workspace/switch-left) (:when (featurep! :ui tabs) - :n "gt" #'centaur-tabs-forward - :n "gT" #'centaur-tabs-backward) + :n "gt" #'+tabs:next-or-goto + :n "gT" #'+tabs:previous-or-got) ;; custom vim-unmpaired-esque keys :m "]#" #'+evil/next-preproc-directive diff --git a/modules/ui/tabs/autoload.el b/modules/ui/tabs/autoload.el new file mode 100644 index 000000000..3970f5eef --- /dev/null +++ b/modules/ui/tabs/autoload.el @@ -0,0 +1,18 @@ +;;; ui/tabs/autoload.el -*- lexical-binding: t; -*- +;;;###if (featurep! :editor evil) + +;;;###autoload (autoload '+tabs:next-or-goto "ui/tabs/autoload" nil t) +(evil-define-command +tabs:next-or-goto (index) + "Switch to the next tab, or to INDEXth tab if a count is given." + (interactive "") + (if current-prefix-arg + (centaur-tabs-select-visible-nth-tab current-prefix-arg) + (centaur-tabs-forward))) + +;;;###autoload (autoload '+tabs:previous-or-goto "ui/tabs/autoload" nil t) +(evil-define-command +tabs:previous-or-goto (index) + "Switch to the previous tab, or to INDEXth tab if a count is given." + (interactive "") + (if current-prefix-arg + (centaur-tabs-select-visible-nth-tab current-prefix-arg) + (centaur-tabs-backward)))