Skip to content

Commit

Permalink
smart splits
Browse files Browse the repository at this point in the history
  • Loading branch information
mosheavni committed Jan 29, 2025
1 parent 19a46ff commit 68ce301
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
3 changes: 2 additions & 1 deletion nvim/.config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"fidget.nvim": { "branch": "main", "commit": "a0abbf18084b77d28bc70e24752e4f4fd54aea17" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"fzf-lua": { "branch": "main", "commit": "7a83b844423c6ec55c445f1de9ad51fe038f5df5" },
"fzf-lua": { "branch": "main", "commit": "fc8c0e6103a52d2075f33f92e96f3187c5ca0f51" },
"git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" },
"gitsigns.nvim": { "branch": "main", "commit": "d8918f06624dd53b9a82bd0e29c31bcfd541b40d" },
"jsonpath.nvim": { "branch": "main", "commit": "2d889eb9c39893e030e902b854122a1615c042ea" },
Expand Down Expand Up @@ -73,6 +73,7 @@
"plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"rose-pine": { "branch": "main", "commit": "42f0724e0bca9f57f0bcfa688787c37b8d4befe8" },
"smart-splits.nvim": { "branch": "master", "commit": "bfb5e63bd4639439b48815f46636dbd52b19b1bd" },
"snacks.nvim": { "branch": "main", "commit": "b96bd540f785c725289f9f15f0147b1b2dac5a35" },
"sqlite.lua": { "branch": "master", "commit": "b487fcc8937b683942a1f7d9662fcf50ca5acd58" },
"statuscol.nvim": { "branch": "0.10", "commit": "b0de00dfcf583bdd94284d844aac1b134d47c578" },
Expand Down
15 changes: 15 additions & 0 deletions nvim/.config/nvim/lua/plugins/functionality.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ local M = {
},
},
},
{
'mrjones2014/smart-splits.nvim',
config = function()
require('smart-splits').setup()
vim.keymap.set('n', '<A-h>', require('smart-splits').resize_left)
vim.keymap.set('n', '<A-j>', require('smart-splits').resize_down)
vim.keymap.set('n', '<A-k>', require('smart-splits').resize_up)
vim.keymap.set('n', '<A-l>', require('smart-splits').resize_right)
-- moving between splits
vim.keymap.set('n', '<C-h>', require('smart-splits').move_cursor_left)
vim.keymap.set('n', '<C-j>', require('smart-splits').move_cursor_down)
vim.keymap.set('n', '<C-k>', require('smart-splits').move_cursor_up)
vim.keymap.set('n', '<C-l>', require('smart-splits').move_cursor_right)
end,
},
}

return M
27 changes: 25 additions & 2 deletions wezterm/.wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ config.keys = {
-- arrow keys keybindings
for _, direction in ipairs { 'Left', 'Right', 'Up', 'Down' } do
-- move between panes
table.insert(config.keys, { key = direction .. 'Arrow', mods = 'CMD|OPT', action = act.ActivatePaneDirection(direction) })
-- table.insert(config.keys, { key = direction .. 'Arrow', mods = 'CMD|OPT', action = act.ActivatePaneDirection(direction) })

-- resize panes
table.insert(config.keys, { key = direction .. 'Arrow', mods = 'CTRL|CMD', action = act.AdjustPaneSize { direction, 3 } })
-- table.insert(config.keys, { key = direction .. 'Arrow', mods = 'CTRL|CMD', action = act.AdjustPaneSize { direction, 3 } })

if direction == 'Left' or direction == 'Right' then
-- Sends ESC + b and ESC + f sequence, which is used
Expand Down Expand Up @@ -163,4 +163,27 @@ for i = 1, 9 do
table.insert(config.keys, { key = tostring(i), mods = 'CMD', action = act.ActivateTab(i - 1) })
end

local smart_splits = wez.plugin.require 'https://github.com/mrjones2014/smart-splits.nvim'
smart_splits.apply_to_config(config, {
-- the default config is here, if you'd like to use the default keys,
-- you can omit this configuration table parameter and just use
-- smart_splits.apply_to_config(config)

-- directional keys to use in order of: left, down, up, right
direction_keys = { 'h', 'j', 'k', 'l' },
-- if you want to use separate direction keys for move vs. resize, you
-- can also do this:
-- direction_keys = {
-- move = { 'h', 'j', 'k', 'l' },
-- resize = { 'LeftArrow', 'DownArrow', 'UpArrow', 'RightArrow' },
-- },
-- modifier keys to combine with direction_keys
modifiers = {
move = 'CTRL', -- modifier to use for pane movement, e.g. CTRL+h to move left
resize = 'META', -- modifier to use for pane resize, e.g. META+h to resize to the left
},
-- log level to use: info, warn, error
log_level = 'info',
})

return config

0 comments on commit 68ce301

Please sign in to comment.