-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
NoNeckPainResize
command (#162)
## 📃 Summary Kind of provides an escape hatch for things like #155 This PR provides a new `NoNeckPainResize` command, that updates the width of the main buffer and triggers a resize of the windows. This can be useful when switching context and the user don't want to update the `setup` method.
- Loading branch information
Showing
8 changed files
with
124 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
local helpers = dofile("tests/helpers.lua") | ||
|
||
local child = helpers.new_child_neovim() | ||
local eq_global, eq_state, eq_buf_width = | ||
helpers.expect.global_equality, helpers.expect.state_equality, helpers.expect.buf_width_equality | ||
|
||
local T = MiniTest.new_set({ | ||
hooks = { | ||
-- This will be executed before every (even nested) case | ||
pre_case = function() | ||
-- Restart child process with custom 'init.lua' script | ||
child.restart({ "-u", "scripts/minimal_init.lua" }) | ||
end, | ||
-- This will be executed one after all tests from this set are finished | ||
post_once = child.stop, | ||
}, | ||
}) | ||
|
||
T["commands"] = MiniTest.new_set() | ||
|
||
T["commands"]["NoNeckPain toggles the plugin state"] = function() | ||
child.cmd("NoNeckPain") | ||
eq_state(child, "enabled", true) | ||
|
||
child.cmd("NoNeckPain") | ||
eq_state(child, "enabled", false) | ||
end | ||
|
||
T["commands"]["NoNeckPainResize sets the config width and resizes windows"] = function() | ||
child.cmd("NoNeckPain") | ||
|
||
eq_global(child, "_G.NoNeckPain.config.width", 100) | ||
|
||
-- need to know why the child isn't precise enough | ||
eq_buf_width(child, "tabs[1].wins.main.curr", 80) | ||
|
||
child.cmd("NoNeckPainResize 20") | ||
|
||
eq_global(child, "_G.NoNeckPain.config.width", 20) | ||
|
||
-- need to know why the child isn't precise enough | ||
eq_buf_width(child, "tabs[1].wins.main.curr", 20) | ||
end | ||
|
||
T["commands"]["NoNeckPainResize throws with the plugin disabled"] = function() | ||
helpers.expect.error(function() | ||
child.cmd("NoNeckPainResize 20") | ||
end) | ||
end | ||
|
||
T["commands"]["NoNeckPainResize does nothing with the same widht"] = function() | ||
child.cmd("NoNeckPain") | ||
|
||
eq_global(child, "_G.NoNeckPain.config.width", 100) | ||
|
||
-- need to know why the child isn't precise enough | ||
eq_buf_width(child, "tabs[1].wins.main.curr", 80) | ||
|
||
child.cmd("NoNeckPainResize 100") | ||
|
||
eq_global(child, "_G.NoNeckPain.config.width", 100) | ||
|
||
-- need to know why the child isn't precise enough | ||
eq_buf_width(child, "tabs[1].wins.main.curr", 80) | ||
end | ||
|
||
return T |