Some checks failed
		
		
	
	Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
				
			Detach Plugins / check (GitHub.vim) (push) Has been cancelled
				
			Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
				
			Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
				
			Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
				
			Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
				
			Detach Plugins / check (git.vim) (push) Has been cancelled
				
			Detach Plugins / check (iedit.vim) (push) Has been cancelled
				
			Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
				
			Detach Plugins / check (vim-chat) (push) Has been cancelled
				
			Detach Plugins / check (vim-cheat) (push) Has been cancelled
				
			Detach Plugins / check (vim-todo) (push) Has been cancelled
				
			Detach Plugins / check (xmake.vim) (push) Has been cancelled
				
			test / Linux (nvim, nightly) (push) Has been cancelled
				
			test / Linux (nvim, v0.3.8) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.4) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.1) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.052) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.629) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
				
			test / Linux (vim, nightly) (push) Has been cancelled
				
			test / Linux (vim, v8.0.0184) (push) Has been cancelled
				
			test / Linux (vim, v8.0.1453) (push) Has been cancelled
				
			test / Linux (vim, v8.1.2269) (push) Has been cancelled
				
			test / Linux (vim, v8.2.2434) (push) Has been cancelled
				
			test / Linux (vim, v8.2.3995) (push) Has been cancelled
				
			test / Windows (nvim, nightly) (push) Has been cancelled
				
			test / Windows (nvim, v0.3.8) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.4) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.1) (push) Has been cancelled
				
			test / Windows (vim, nightly) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1185) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1689) (push) Has been cancelled
				
			test / Windows (vim, v8.0.0027) (push) Has been cancelled
				
			test / Windows (vim, v8.0.1453) (push) Has been cancelled
				
			test / Windows (vim, v8.1.2269) (push) Has been cancelled
				
			test / Windows (vim, v8.2.2434) (push) Has been cancelled
				
			test / Windows (vim, v8.2.3995) (push) Has been cancelled
				
			docker / docker (push) Has been cancelled
				
			mirror / check (coding) (push) Has been cancelled
				
			mirror / check (gitee) (push) Has been cancelled
				
			mirror / check (gitlab) (push) Has been cancelled
				
			
		
			
				
	
	
		
			241 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			241 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
# Layout
 | 
						|
 | 
						|
Layout is a helper component for creating complex layout by automatically
 | 
						|
handling the calculation for position and size of other components.
 | 
						|
 | 
						|
**Example**
 | 
						|
 | 
						|
```lua
 | 
						|
local Layout = require("nui.layout")
 | 
						|
local Popup = require("nui.popup")
 | 
						|
 | 
						|
local top_popup = Popup({ border = "single" })
 | 
						|
local bottom_popup = Popup({ border = "double" })
 | 
						|
 | 
						|
local layout = Layout(
 | 
						|
  {
 | 
						|
    position = "50%",
 | 
						|
    size = {
 | 
						|
      width = 80,
 | 
						|
      height = 40,
 | 
						|
    },
 | 
						|
  },
 | 
						|
  Layout.Box({
 | 
						|
    Layout.Box(top_popup, { size = "40%" }),
 | 
						|
    Layout.Box(bottom_popup, { size = "60%" }),
 | 
						|
  }, { dir = "col" })
 | 
						|
)
 | 
						|
 | 
						|
layout:mount()
 | 
						|
```
 | 
						|
 | 
						|
_Signature:_ `Layout(options, box)` or `Layout(component, box)`
 | 
						|
 | 
						|
`component` can be `Popup` or `Split`.
 | 
						|
 | 
						|
## Options
 | 
						|
 | 
						|
### `relative`
 | 
						|
 | 
						|
**Type:** `string` or `table`
 | 
						|
 | 
						|
This option affects how `position` and `size` are calculated.
 | 
						|
 | 
						|
**Examples**
 | 
						|
 | 
						|
Relative to cursor on current window:
 | 
						|
 | 
						|
```lua
 | 
						|
relative = "cursor",
 | 
						|
```
 | 
						|
 | 
						|
Relative to the current editor screen:
 | 
						|
 | 
						|
```lua
 | 
						|
relative = "editor",
 | 
						|
```
 | 
						|
 | 
						|
Relative to the current window (_default_):
 | 
						|
 | 
						|
```lua
 | 
						|
relative = "win",
 | 
						|
```
 | 
						|
 | 
						|
Relative to the window with specific id:
 | 
						|
 | 
						|
```lua
 | 
						|
relative = {
 | 
						|
  type = "win",
 | 
						|
  winid = 5,
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
Relative to the buffer position:
 | 
						|
 | 
						|
```lua
 | 
						|
relative = {
 | 
						|
  type = "buf",
 | 
						|
  -- zero-indexed
 | 
						|
  position = {
 | 
						|
    row = 5,
 | 
						|
    col = 5,
 | 
						|
  },
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
---
 | 
						|
 | 
						|
### `position`
 | 
						|
 | 
						|
**Type:** `number` or `percentage string` or `table`
 | 
						|
 | 
						|
Position is calculated from the top-left corner.
 | 
						|
 | 
						|
If `position` is `number` or `percentage string`, it applies to both `row` and `col`.
 | 
						|
Or you can pass a table to set them separately.
 | 
						|
 | 
						|
For `percentage string`, position is calculated according to the option `relative`.
 | 
						|
If `relative` is set to `"buf"` or `"cursor"`, `percentage string` is not allowed.
 | 
						|
 | 
						|
**Examples**
 | 
						|
 | 
						|
```lua
 | 
						|
position = 50,
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
position = "50%",
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
position = {
 | 
						|
  row = 30,
 | 
						|
  col = 20,
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
position = {
 | 
						|
  row = "20%",
 | 
						|
  col = "50%",
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
---
 | 
						|
 | 
						|
### `size`
 | 
						|
 | 
						|
**Type:** `number` or `percentage string` or `table`
 | 
						|
 | 
						|
Determines the size of the layout.
 | 
						|
 | 
						|
If `size` is `number` or `percentage string`, it applies to both `width` and `height`.
 | 
						|
You can also pass a table to set them separately.
 | 
						|
 | 
						|
For `percentage string`, `size` is calculated according to the option `relative`.
 | 
						|
If `relative` is set to `"buf"` or `"cursor"`, window size is considered.
 | 
						|
 | 
						|
**Examples**
 | 
						|
 | 
						|
```lua
 | 
						|
size = 50,
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
size = "50%",
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
size = {
 | 
						|
  width = 80,
 | 
						|
  height = 40,
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
```lua
 | 
						|
size = {
 | 
						|
  width = "80%",
 | 
						|
  height = "60%",
 | 
						|
},
 | 
						|
```
 | 
						|
 | 
						|
## Layout.Box
 | 
						|
 | 
						|
_Signature:_ `Layout.Box(box, options)`
 | 
						|
 | 
						|
**Parameters**
 | 
						|
 | 
						|
| Name      | Type                           | Description                               |
 | 
						|
| --------- | ------------------------------ | ----------------------------------------- |
 | 
						|
| `box`     | `Layout.Box[]` / nui component | list of `Layout.Box` or any nui component |
 | 
						|
| `options` | `table`                        | box options                               |
 | 
						|
 | 
						|
`options` is a `table` having the following keys:
 | 
						|
 | 
						|
| Key    | Type                          | Description                                            |
 | 
						|
| ------ | ----------------------------- | ------------------------------------------------------ |
 | 
						|
| `dir`  | `"col"` / `"row"` (_default_) | arrangement direction, only if `box` is `Layout.Box[]` |
 | 
						|
| `grow` | `number`                      | growth factor to fill up the box free space            |
 | 
						|
| `size` | `number` / `string` / `table` | optional if `grow` is present                          |
 | 
						|
 | 
						|
## Methods
 | 
						|
 | 
						|
### `layout:mount`
 | 
						|
 | 
						|
_Signature:_ `layout:mount()`
 | 
						|
 | 
						|
Mounts the layout with all the components.
 | 
						|
 | 
						|
**Examples**
 | 
						|
 | 
						|
```lua
 | 
						|
layout:mount()
 | 
						|
```
 | 
						|
 | 
						|
### `layout:unmount`
 | 
						|
 | 
						|
_Signature:_ `layout:unmount()`
 | 
						|
 | 
						|
Unmounts the layout with all the components.
 | 
						|
 | 
						|
**Examples**
 | 
						|
 | 
						|
```lua
 | 
						|
layout:unmount()
 | 
						|
```
 | 
						|
 | 
						|
### `layout:hide`
 | 
						|
 | 
						|
_Signature:_ `layout:hide()`
 | 
						|
 | 
						|
Hides the layout with all the components. Preserves the buffer (related content, autocmds and keymaps).
 | 
						|
 | 
						|
### `layout:show`
 | 
						|
 | 
						|
_Signature:_ `layout:show()`
 | 
						|
 | 
						|
Shows the hidden layout with all the components.
 | 
						|
 | 
						|
### `layout:update`
 | 
						|
 | 
						|
_Signature:_ `layout:update(config, box?)` or `layout:update(box?)`
 | 
						|
 | 
						|
**Parameters**
 | 
						|
 | 
						|
`config` is a `table` having the following keys:
 | 
						|
 | 
						|
| Key        | Type               |
 | 
						|
| ---------- | ------------------ |
 | 
						|
| `relative` | `string` / `table` |
 | 
						|
| `position` | `string` / `table` |
 | 
						|
| `size`     | `string` / `table` |
 | 
						|
 | 
						|
`box` is a `table` returned by `Layout.Box`.
 | 
						|
 | 
						|
They are the same options used for layout initialization.
 | 
						|
 | 
						|
## Wiki Page
 | 
						|
 | 
						|
You can find additional documentation/examples/guides/tips-n-tricks in
 | 
						|
[nui.layout wiki page](https://github.com/MunifTanjim/nui.nvim/wiki/nui.layout).
 |