From e8ff6ac5f304f3c315d681c4cb744ba746f22e92 Mon Sep 17 00:00:00 2001 From: jasmine Date: Mon, 19 May 2025 09:37:24 +0800 Subject: [PATCH] add smart splits --- config/default.nix | 1 + config/keymaps.nix | 36 -------- config/plugins/editor/smart-splits.nix | 110 +++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 config/plugins/editor/smart-splits.nix diff --git a/config/default.nix b/config/default.nix index 3dd9bf6..d2f658f 100644 --- a/config/default.nix +++ b/config/default.nix @@ -20,6 +20,7 @@ ./plugins/editor/buffers.nix ./plugins/editor/comment.nix ./plugins/editor/sessions.nix + ./plugins/editor/smart-splits.nix ./plugins/editor/treesitter.nix # UI plugins diff --git a/config/keymaps.nix b/config/keymaps.nix index b87f479..0bbc0f0 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -19,41 +19,5 @@ desc = "+find"; }; } - - { # focus window left - mode = ["n"]; - key = ""; - action = "h"; - options = { - silent = true; - }; - } - - { # focus window down - mode = ["n"]; - key = ""; - action = "j"; - options = { - silent = true; - }; - } - - { # focus window up - mode = ["n"]; - key = ""; - action = "k"; - options = { - silent = true; - }; - } - - { # focus window right - mode = ["n"]; - key = ""; - action = "l"; - options = { - silent = true; - }; - } ]; } diff --git a/config/plugins/editor/smart-splits.nix b/config/plugins/editor/smart-splits.nix new file mode 100644 index 0000000..46aeb28 --- /dev/null +++ b/config/plugins/editor/smart-splits.nix @@ -0,0 +1,110 @@ +{...}: { + plugins.smart-splits = { + enable = true; + + settings = { + multiplexer_integration = "WezTerm"; + }; + }; + + keymaps = [ + # moving between splits + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_right"; + }; + } + + # swapping buffers between windows + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_right"; + }; + } + + # resizing splits + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_right"; + }; + } + ]; +}