feat: add tabline support (#92)

This commit is contained in:
Shadman 2021-03-06 21:03:00 +06:00 committed by GitHub
parent 9c9212c5b6
commit 332f488e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 123 additions and 41 deletions

View File

@ -274,6 +274,33 @@ lualine.sections.lualine_b = {
</details>
### 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)

View File

@ -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|
@ -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*

View File

@ -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*

View File

@ -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