diff --git a/README.md b/README.md index 9e45fa6..cddb2c8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/doc/lualine.txt b/doc/lualine.txt index 20c780a..b624ffc 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -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. diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index c5adb51..8ef0dd0 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -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)