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>
|
</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
|
### 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)
|
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.4. Changing components.................|lualine_changing_components|
|
||||||
1.3.5. Building Custom components............|lualine_custom_components|
|
1.3.5. Building Custom components............|lualine_custom_components|
|
||||||
1.3.6. Custom options...........................|lualine_custom_options|
|
1.3.6. Custom options...........................|lualine_custom_options|
|
||||||
1.3.7. Loading plugin extensions.....|lualine_loading_plugin_extensions|
|
1.3.7. Using tabline as statusline...............|lualine_using_tabline|
|
||||||
1.3.8 Config examples.........................|lualine_config_examples|
|
1.3.8. Loading plugin extensions.....|lualine_loading_plugin_extensions|
|
||||||
1.3.8.1. Packer.nvim......|lualine_config_example_using_packer.nvim|
|
1.3.9 Config examples.........................|lualine_config_examples|
|
||||||
1.3.8.2 VIML example.......|lualine_full_config_example_inside_viml|
|
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.4. Contributing.....................................|lualine_contributing|
|
||||||
1.5. Screenshots.......................................|lualine_screenshots|
|
1.5. Screenshots.......................................|lualine_screenshots|
|
||||||
|
|
||||||
|
@ -376,7 +377,34 @@ Example:~
|
||||||
end
|
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*
|
LOADING PLUGIN EXTENSIONS *lualine_loading_plugin_extensions*
|
||||||
|
|
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_setting_theme lualine.txt /*lualine_setting_theme*
|
||||||
lualine_starting_lualine lualine.txt /*lualine_starting_lualine*
|
lualine_starting_lualine lualine.txt /*lualine_starting_lualine*
|
||||||
lualine_usage_and_customization lualine.txt /*lualine_usage_and_customization*
|
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*
|
lualine_vim-plug lualine.txt /*lualine_vim-plug*
|
||||||
|
|
|
@ -35,6 +35,8 @@ M.inactive_sections = {
|
||||||
lualine_z = { }
|
lualine_z = { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M.tabline = {}
|
||||||
|
|
||||||
M.extensions = { }
|
M.extensions = { }
|
||||||
|
|
||||||
local function apply_configuration(config_table)
|
local function apply_configuration(config_table)
|
||||||
|
@ -59,6 +61,7 @@ local function apply_configuration(config_table)
|
||||||
parse_sections('options')
|
parse_sections('options')
|
||||||
parse_sections('sections')
|
parse_sections('sections')
|
||||||
parse_sections('inactive_sections')
|
parse_sections('inactive_sections')
|
||||||
|
parse_sections('tabline')
|
||||||
if config_table.extensions then M.extensions = config_table.extensions end
|
if config_table.extensions then M.extensions = config_table.extensions end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -168,6 +171,7 @@ local function load_components()
|
||||||
end
|
end
|
||||||
load_sections(M.sections)
|
load_sections(M.sections)
|
||||||
load_sections(M.inactive_sections)
|
load_sections(M.inactive_sections)
|
||||||
|
load_sections(M.tabline)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function load_extensions()
|
local function load_extensions()
|
||||||
|
@ -283,27 +287,49 @@ local function status_dispatch()
|
||||||
end
|
end
|
||||||
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_set_theme = lualine_set_theme
|
||||||
_G.lualine_statusline = status_dispatch
|
|
||||||
vim.api.nvim_exec([[
|
vim.api.nvim_exec([[
|
||||||
augroup lualine
|
augroup lualine
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd ColorScheme * call v:lua.lualine_set_theme()
|
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
|
augroup END
|
||||||
]], false)
|
]], false)
|
||||||
end
|
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)
|
function M.status(config)
|
||||||
apply_configuration(vim.g.lualine)
|
apply_configuration(vim.g.lualine)
|
||||||
apply_configuration(config)
|
apply_configuration(config)
|
||||||
check_single_separator()
|
check_single_separator()
|
||||||
lualine_set_theme()
|
setup_theme()
|
||||||
exec_autocommands()
|
|
||||||
load_components()
|
load_components()
|
||||||
load_extensions()
|
load_extensions()
|
||||||
|
set_statusline()
|
||||||
|
set_tabline()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue