diff --git a/README.md b/README.md index 63e30e3..3d702ec 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,33 @@ lualine.sections.lualine_b = { +### Using tabline as statusline +You can use lualine to display components in tabline . +The sections, configurations and highlights are same as statusline. + +``` +lualine.tabline = { + lualine_a = { }, + lualine_b = { 'branch' }, + lualine_c = { 'filename' }, + lualine_x = { }, + lualine_y = { }, + lualine_z = { }, +} +``` +This will show branch and filename component in top of neovim inside tabline . + + +You can also completely move your statuline to tabline by configuring lualine.tabline +instead of lualine.sections & lualine.inactive_sections and setting them to empty +``` +lualine.tabline = { +...... + } +lualine.sections = {} +lualine.inactive_sections = {} +``` + ### Loading plugin extensions Lualine extensions change statusline appearance for a window/buffer with a plugin loaded e.g. [junegunn/fzf.vim](https://github.com/junegunn/fzf.vim) diff --git a/doc/lualine.txt b/doc/lualine.txt index c615d1b..c4d85a8 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -37,10 +37,11 @@ CONTENTS *lualine_contents* 1.3.4. Changing components.................|lualine_changing_components| 1.3.5. Building Custom components............|lualine_custom_components| 1.3.6. Custom options...........................|lualine_custom_options| - 1.3.7. Loading plugin extensions.....|lualine_loading_plugin_extensions| - 1.3.8 Config examples.........................|lualine_config_examples| - 1.3.8.1. Packer.nvim......|lualine_config_example_using_packer.nvim| - 1.3.8.2 VIML example.......|lualine_full_config_example_inside_viml| + 1.3.7. Using tabline as statusline...............|lualine_using_tabline| + 1.3.8. Loading plugin extensions.....|lualine_loading_plugin_extensions| + 1.3.9 Config examples.........................|lualine_config_examples| + 1.3.9.1. Packer.nvim......|lualine_config_example_using_packer.nvim| + 1.3.9.2 VIML example.......|lualine_full_config_example_inside_viml| 1.4. Contributing.....................................|lualine_contributing| 1.5. Screenshots.......................................|lualine_screenshots| @@ -346,13 +347,13 @@ List of options are given below. Changes diff's symbol characters. You can set some symbols partly. Color in #rrggbb format > - { - 'diff', - -- set the added symbol and use defaults for modified and removed. - symbols = { - added = 'A', - }, - } + { + 'diff', + -- set the added symbol and use defaults for modified and removed. + symbols = { + added = 'A', + }, + } < Example:~ @@ -376,7 +377,34 @@ Example:~ end } } +------------------------------------------------------------------------------- +USING TABLINE AS STATUSLINE *lualine_using_tabline* + +You can use lualine to display components in tabline . +The sections, configurations and highlights are same as statusline. + +> + lualine.tabline = { + lualine_a = { }, + lualine_b = { 'branch' }, + lualine_c = { 'filename' }, + lualine_x = { }, + lualine_y = { }, + lualine_z = { }, + } < +This will show branch and filename component in top of neovim inside tabline . + +You can also completely move your statuline to tabline by configuring lualine.tabline +instead of lualine.sections & lualine.inactive_sections and setting them to empty +> + lualine.tabline = { + ...... + } + lualine.sections = {} + lualine.inactive_sections = {} +< + -------------------------------------------------------------------------------- LOADING PLUGIN EXTENSIONS *lualine_loading_plugin_extensions* @@ -441,30 +469,30 @@ FULL CONFIG EXAMPLE INSIDE VIML *lualine_full_config_example_inside_viml* vimrc config > let g:lualine = { - \'options' : { - \ 'theme' : 'gruvbox', - \ 'section_separators' : ['', ''], - \ 'component_separators' : ['', ''], - \ 'icons_enabled' : v:true, - \}, - \'sections' : { - \ 'lualine_a' : [ ['mode', {'upper': v:true,},], ], - \ 'lualine_b' : [ ['branch', {'icon': '',}, ], ], - \ 'lualine_c' : [ ['filename', {'file_status': v:true,},], ], - \ 'lualine_x' : [ 'encoding', 'fileformat', 'filetype' ], - \ 'lualine_y' : [ 'progress' ], - \ 'lualine_z' : [ 'location' ], - \}, - \'inactive_sections' : { - \ 'lualine_a' : [ ], - \ 'lualine_b' : [ ], - \ 'lualine_c' : [ 'filename' ], - \ 'lualine_x' : [ 'location' ], - \ 'lualine_y' : [ ], - \ 'lualine_z' : [ ], - \}, - \'extensions' : [ 'fzf' ], - \} + \'options' : { + \ 'theme' : 'gruvbox', + \ 'section_separators' : ['', ''], + \ 'component_separators' : ['', ''], + \ 'icons_enabled' : v:true, + \}, + \'sections' : { + \ 'lualine_a' : [ ['mode', {'upper': v:true,},], ], + \ 'lualine_b' : [ ['branch', {'icon': '',}, ], ], + \ 'lualine_c' : [ ['filename', {'file_status': v:true,},], ], + \ 'lualine_x' : [ 'encoding', 'fileformat', 'filetype' ], + \ 'lualine_y' : [ 'progress' ], + \ 'lualine_z' : [ 'location' ], + \}, + \'inactive_sections' : { + \ 'lualine_a' : [ ], + \ 'lualine_b' : [ ], + \ 'lualine_c' : [ 'filename' ], + \ 'lualine_x' : [ 'location' ], + \ 'lualine_y' : [ ], + \ 'lualine_z' : [ ], + \}, + \'extensions' : [ 'fzf' ], + \} lua require("lualine").status() < diff --git a/doc/tags b/doc/tags index cfa3558..b37c93a 100644 --- a/doc/tags +++ b/doc/tags @@ -19,4 +19,5 @@ lualine_screenshots lualine.txt /*lualine_screenshots* lualine_setting_theme lualine.txt /*lualine_setting_theme* lualine_starting_lualine lualine.txt /*lualine_starting_lualine* lualine_usage_and_customization lualine.txt /*lualine_usage_and_customization* +lualine_using_tabline lualine.txt /*lualine_using_tabline* lualine_vim-plug lualine.txt /*lualine_vim-plug* diff --git a/lua/lualine.lua b/lua/lualine.lua index 3f73257..77c105b 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -35,6 +35,8 @@ M.inactive_sections = { lualine_z = { } } +M.tabline = {} + M.extensions = { } local function apply_configuration(config_table) @@ -59,6 +61,7 @@ local function apply_configuration(config_table) parse_sections('options') parse_sections('sections') parse_sections('inactive_sections') + parse_sections('tabline') if config_table.extensions then M.extensions = config_table.extensions end end @@ -168,6 +171,7 @@ local function load_components() end load_sections(M.sections) load_sections(M.inactive_sections) + load_sections(M.tabline) end local function load_extensions() @@ -283,27 +287,49 @@ local function status_dispatch() end end -local function exec_autocommands() +local function tabline() + return statusline(M.tabline, true) +end + +local function setup_theme() + lualine_set_theme() _G.lualine_set_theme = lualine_set_theme - _G.lualine_statusline = status_dispatch vim.api.nvim_exec([[ augroup lualine autocmd! autocmd ColorScheme * call v:lua.lualine_set_theme() - autocmd WinLeave,BufLeave * lua vim.wo.statusline=lualine_statusline() - autocmd WinEnter,BufEnter * setlocal statusline=%!v:lua.lualine_statusline() augroup END ]], false) end +local function set_tabline() + if next(M.tabline) ~= nil then + _G.lualine_tabline = tabline + vim.o.tabline = '%!v:lua.lualine_tabline()' + vim.o.showtabline = 2 + end +end + +local function set_statusline() + if next(M.sections) ~= nil or next(M.inactive_sections) ~= nil then + _G.lualine_statusline = status_dispatch + vim.o.statusline = '%!v:lua.lualine_statusline()' + vim.api.nvim_exec([[ + autocmd lualine WinLeave,BufLeave * lua vim.wo.statusline=lualine_statusline() + autocmd lualine WinEnter,BufEnter * setlocal statusline=%!v:lua.lualine_statusline() + ]], false) + end +end + function M.status(config) apply_configuration(vim.g.lualine) apply_configuration(config) check_single_separator() - lualine_set_theme() - exec_autocommands() + setup_theme() load_components() load_extensions() + set_statusline() + set_tabline() end return M