feat: Allow (neo)vim's statusline items to be used as component directly
This commit is contained in:
parent
aa65ef46fd
commit
849d6acc66
|
@ -207,6 +207,12 @@ sections = {lualine_a = {hello}}
|
|||
sections = {lualine_a = {'FugitiveHead'}}
|
||||
```
|
||||
|
||||
#### Vim's statusline items as lualine component
|
||||
|
||||
```lua
|
||||
sections = {lualine_c = {'%=', '%t%m', '%3p'}}
|
||||
```
|
||||
|
||||
##### Vim variables as lualine component
|
||||
Variables from `g:`, `v:`, `t:`, `w:`, `b:`, `o`, `go:`, `vo:`, `to:`, `wo:`, `bo:` scopes can be used.
|
||||
|
||||
|
@ -222,7 +228,7 @@ You can use any valid lua expression as a component including
|
|||
* global variables
|
||||
* require statements
|
||||
```lua
|
||||
sections = {lualine_c = {"os.data('%a')", 'data', require'lsp-status'.status}}
|
||||
sections = {lualine_c = {"os.data('%a')", 'data', "require'lsp-status'.status()"}}
|
||||
```
|
||||
`data` is a global variable in this example.
|
||||
|
||||
|
|
|
@ -149,6 +149,11 @@ Vim functions as lualine component~
|
|||
>
|
||||
sections = {lualine_a = {'FugitiveHead'}}
|
||||
<
|
||||
Vim's statusline items as lualine component~
|
||||
>
|
||||
sections = {lualine_c = {'%=', '%t%m', '%3p'}}
|
||||
<
|
||||
|
||||
Vim variables as lualine component~
|
||||
|
||||
Variables from `g:`, `v:`, `t:`, `w:`, `b:`, `o`, `go:`, `vo:`, `to:`, `wo:`, `bo:` scopes can be used.
|
||||
|
|
|
@ -70,6 +70,11 @@ local function component_loader(component)
|
|||
if ok then
|
||||
component.component_name = component[1]
|
||||
loaded_component = loaded_component:new(component)
|
||||
elseif string.char(component[1]:byte(1)) == '%' then
|
||||
local stl_expr = component[1] -- Vim's %p %l statusline elements
|
||||
component[1] = function() return stl_expr end
|
||||
loaded_component =
|
||||
lualine_load({'lua', 'lualine', 'components', 'special', 'function_component'}, true):new(component)
|
||||
elseif component[1]:find('[gvtwb]?o?:') == 1 then
|
||||
loaded_component =
|
||||
lualine_load({'lua', 'lualine', 'components', 'special', 'vim_var_component'}, true):new(component)
|
||||
|
|
Loading…
Reference in New Issue