feat: add tabline support (#92)
This commit is contained in:
parent
9c9212c5b6
commit
332f488e24
27
README.md
27
README.md
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
<
|
||||
|
||||
|
|
1
doc/tags
1
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*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue