-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathinit.lua
More file actions
115 lines (97 loc) 路 3.72 KB
/
Copy pathinit.lua
File metadata and controls
115 lines (97 loc) 路 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
local M = {}
---The multiplexer protocol version this release implements. Backends can assert
---against it, see PROTOCOL.md.
M.PROTOCOL_VERSION = require('smart-splits.backend').PROTOCOL_VERSION
M.SUPPORTED_VERSIONS = require('smart-splits.backend').SUPPORTED_VERSIONS
---@class (partial) SmartSplitsSetupOpts: SmartSplitsConfig
---Configure the plugin. Optional; without it you get the defaults and no
---multiplexer backend.
---@param opts SmartSplitsSetupOpts|nil
function M.setup(opts)
require('smart-splits.config').setup(opts)
end
---@param direction SmartSplitsDirection
---@param opts SmartSplitsMoveOpts|nil
local function move(direction, opts)
local ok, err = pcall(require('smart-splits.move').move_cursor, direction, opts)
if not ok then
require('smart-splits.log').error('failed to move cursor %s: %s', direction, err)
end
end
---@param direction SmartSplitsDirection
---@param opts SmartSplitsSwapOpts|nil
local function swap(direction, opts)
local ok, err = pcall(require('smart-splits.swap').swap_bufs, direction, opts)
if not ok then
require('smart-splits.log').error('failed to swap buffers %s: %s', direction, err)
end
end
---Resize the current window to the left, delegating to the multiplexer when the
---window already spans the full width.
---@param opts number|SmartSplitsResizeOpts|nil a bare number means `amount`
function M.resize_left(opts)
require('smart-splits.resize').run('left', opts)
end
---Resize the current window to the right, delegating to the multiplexer when the
---window already spans the full width.
---@param opts number|SmartSplitsResizeOpts|nil a bare number means `amount`
function M.resize_right(opts)
require('smart-splits.resize').run('right', opts)
end
---Resize the current window upwards, delegating to the multiplexer when the
---window already spans the full height.
---@param opts number|SmartSplitsResizeOpts|nil a bare number means `amount`
function M.resize_up(opts)
require('smart-splits.resize').run('up', opts)
end
---Resize the current window downwards, delegating to the multiplexer when the
---window already spans the full height.
---@param opts number|SmartSplitsResizeOpts|nil a bare number means `amount`
function M.resize_down(opts)
require('smart-splits.resize').run('down', opts)
end
---Move the cursor to the window on the left, or to the multiplexer pane there
---when already at the leftmost window.
---@param opts SmartSplitsMoveOpts|nil
function M.move_cursor_left(opts)
move('left', opts)
end
---Move the cursor to the window on the right, or to the multiplexer pane there
---when already at the rightmost window.
---@param opts SmartSplitsMoveOpts|nil
function M.move_cursor_right(opts)
move('right', opts)
end
---Move the cursor to the window above, or to the multiplexer pane there when
---already at the topmost window.
---@param opts SmartSplitsMoveOpts|nil
function M.move_cursor_up(opts)
move('up', opts)
end
---Move the cursor to the window below, or to the multiplexer pane there when
---already at the bottommost window.
---@param opts SmartSplitsMoveOpts|nil
function M.move_cursor_down(opts)
move('down', opts)
end
---Swap the current buffer with the one in the window to the left.
---@param opts SmartSplitsSwapOpts|nil
function M.swap_buf_left(opts)
swap('left', opts)
end
---Swap the current buffer with the one in the window to the right.
---@param opts SmartSplitsSwapOpts|nil
function M.swap_buf_right(opts)
swap('right', opts)
end
---Swap the current buffer with the one in the window above.
---@param opts SmartSplitsSwapOpts|nil
function M.swap_buf_up(opts)
swap('up', opts)
end
---Swap the current buffer with the one in the window below.
---@param opts SmartSplitsSwapOpts|nil
function M.swap_buf_down(opts)
swap('down', opts)
end
return M