Skip to content

Commit 8d77c1b

Browse files
committed
docs: added layout feature
1 parent f781d21 commit 8d77c1b

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ A simple plugin for [taskfiles](https://taskfile.dev/)
1313
- Run tasks in a floating terminal
1414
- Automatically scroll to bottom of output (optional)
1515
- Rerun last task via command or key-map
16-
- Flexible layout with width_ratio or auto-sizing to fit
17-
task names and descriptions neatly
16+
- Flexible layouts:
17+
- **Horizontal**: task list and preview side-by-side
18+
- **Vertical**: task list stacked above preview
19+
- Configurable `width_ratio` / `height_ratio` or automatic sizing
20+
to neatly fit task names and descriptions
21+
- Toggle between horizontal and vertical layouts at runtime
1822

1923
## Requirements
2024

@@ -39,6 +43,9 @@ All fields are optional and shown below with their default values:
3943

4044
```lua
4145
require('taskfile').setup({
46+
layout = "horizontal", -- Layout: 'h', 'horiz', 'horizontal' or 'v', 'vert', 'vertical'.
47+
-- For 'horizontal' layout, list and preview are side-by-side.
48+
-- For 'vertical', list is above preview (vertically stacked).
4249
windows = {
4350
output = { -- Task output window
4451
width = 0.8, -- Width of the window (percentage of editor width)
@@ -48,11 +55,18 @@ require('taskfile').setup({
4855
list = { -- Task list and preview window
4956
width = 0.6,
5057
height = 0.4,
51-
border = "rounded"
58+
border = "rounded",
59+
-- only used for horizontal layout
5260
width_ratio = 0, -- Ratio (0–1) of list vs preview width.
5361
-- If set, determines how much space is given to the list.
5462
-- If unset or 0, the list width is calculated to fit
5563
-- longest task name and description without wrapping.
64+
-- only used for vertical layout
65+
height_ratio = 0, -- Ratio (0–1) of list vs preview height.
66+
-- If set, determines how much space is given to the list.
67+
-- If unset or 0, the list height is calculated to fit
68+
-- the rendered task lines (name + description),
69+
-- wrapping as needed, without overflow.
5670
},
5771
},
5872
scroll = {
@@ -73,6 +87,8 @@ This plugin reads your Taskfile and displays available tasks.
7387
- `:Task <task_name>`: Run a specific task by name
7488
- `:Task`: Show a floating task selector with preview
7589
- `:TaskRerun`: Rerun the last executed task
90+
- `:TaskToggleLayout`: Toggles the layout for the current Neovim session.
91+
On restart, it resets to your configured default.
7692

7793
You can also bind a key to rerun using the `keymaps.rerun` config.
7894

demo/demo.gif

271 KB
Loading

demo/demo.tape

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Set MarginFill "#3D4262"
88
Set BorderRadius 7
99

1010

11-
Set Width 1600
11+
Set Width 1440
1212
Set Height 900
13-
Set FontSize 14
13+
Set FontSize 16
1414

1515
Hide
1616
Type "cd $HOME/git/examples/go-web-app"
@@ -27,6 +27,11 @@ Sleep 750ms
2727
Enter
2828
Sleep 750ms
2929

30+
Type ":TaskToggleLayout"
31+
Sleep 500ms
32+
Enter
33+
Sleep 500ms
34+
3035
Type "j"
3136
Sleep 1000ms
3237
Enter
@@ -45,6 +50,11 @@ Sleep 1000ms
4550
Enter
4651
Sleep 1000ms
4752

53+
Type ":TaskToggleLayout"
54+
Sleep 500ms
55+
Enter
56+
Sleep 500ms
57+
4858
Type "j"
4959
Sleep 500ms
5060
Type "j"

tests/taskfile/ui_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ describe("ui integration", function()
473473

474474
it("horizontal honors width_ratio and ignores height_ratio", function()
475475
local cfg_width = 0.9
476-
local total_weight = math.floor(vim.o.columns * cfg_width)
476+
local total_width = math.floor(vim.o.columns * cfg_width)
477477
local width_ratio = 0.3
478478

479479
ui.select_task_with_preview(require("taskfile.core").get_tasks(), {
@@ -487,8 +487,8 @@ describe("ui integration", function()
487487

488488
local list_cfg, preview_cfg = win_cfg(ui._list_win), win_cfg(ui._preview_win)
489489

490-
assert.are.equal(math.floor(total_weight * width_ratio), list_cfg.width)
491-
assert.are.equal(total_weight, list_cfg.width + 2 + preview_cfg.width) -- gap=2
490+
assert.are.equal(math.floor(total_width * width_ratio), list_cfg.width)
491+
assert.are.equal(total_width, list_cfg.width + ui.const.WINDOW_GAP + preview_cfg.width)
492492
end)
493493

494494
it("vertical honors height_ratio and ignores width_ratio", function()

0 commit comments

Comments
 (0)