Feat: Disable lualine om specific buffer (#206)
Adding a new option in options table named `disabled_filetypes` . It's a list of filetypes . If current filetyoe is on the list statusline will be disabled.
This commit is contained in:
parent
fcec65648c
commit
4c3d76d9cf
|
@ -252,6 +252,7 @@ lower | false | Changes components to be lowercase | All
|
|||
format | nil | Takes a function . The funtion gets the result of component as argument and it's return value is displayed. So this function can parse and format the output as user wants. | All
|
||||
condition | nil | Takes a function. The component is loaded if the function returns true otherwise not. It can be used to load some comoonents on specific cases. | All
|
||||
color | nil | Sets custom color for the component in this format<br></br>`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`<br></br>The fields of color table are optional and default to theme <br></br>Color option can also be a string containing highlight group name `color = "WarningMsg"`. One neat trick set the color to highlight group name then change that highlight with :hi command to change color of that component at runtime. | All
|
||||
disabled_filetypes | {} | Disables lualine for specific filetypes | It works on entire statusline instead of on a single component
|
||||
|
||||
#### Using global options
|
||||
Global options can be set in two ways. One is as part of options table in setup.
|
||||
|
@ -404,6 +405,7 @@ extensions = { 'fzf' }
|
|||
theme = 'gruvbox',
|
||||
section_separators = {'', ''},
|
||||
component_separators = {'', ''},
|
||||
disabled_filetypes = {},
|
||||
icons_enabled = true,
|
||||
},
|
||||
sections = {
|
||||
|
@ -441,6 +443,7 @@ let g:lualine = {
|
|||
\ 'theme' : 'gruvbox',
|
||||
\ 'section_separators' : ['', ''],
|
||||
\ 'component_separators' : ['', ''],
|
||||
\ 'disabled_filetypes' : [],
|
||||
\ 'icons_enabled' : v:true,
|
||||
\},
|
||||
\'sections' : {
|
||||
|
|
|
@ -295,6 +295,10 @@ option (default_value)
|
|||
can parse and format the output as user wants.
|
||||
Supported components: all
|
||||
|
||||
• disabled_filetypes ({})
|
||||
Disables lualine for specific filetypes. It works on entire
|
||||
statusline instead of on a single component.
|
||||
|
||||
Example:
|
||||
`lualine.options.icons_enabled = true`
|
||||
|
||||
|
@ -522,6 +526,7 @@ Lua config example
|
|||
theme = 'gruvbox',
|
||||
section_separators = {'', ''},
|
||||
component_separators = {'', ''},
|
||||
disabled_filetypes = {},
|
||||
icons_enabled = true,
|
||||
},
|
||||
sections = {
|
||||
|
@ -553,6 +558,7 @@ Vimscript config example
|
|||
\ 'theme' : 'gruvbox',
|
||||
\ 'section_separators' : ['', ''],
|
||||
\ 'component_separators' : ['', ''],
|
||||
\ 'disabled_filetypes' : [],
|
||||
\ 'icons_enabled' : v:true,
|
||||
\},
|
||||
\'sections' : {
|
||||
|
|
|
@ -4,7 +4,8 @@ M.options = {
|
|||
icons_enabled = true,
|
||||
theme = 'gruvbox',
|
||||
component_separators = {'', ''},
|
||||
section_separators = {'', ''}
|
||||
section_separators = {'', ''},
|
||||
disabled_filetypes = {},
|
||||
}
|
||||
|
||||
M.sections = {
|
||||
|
|
|
@ -65,7 +65,8 @@ end
|
|||
|
||||
local function component_loader(component)
|
||||
if type(component[1]) == 'function' then
|
||||
return require 'lualine.components.special.function_component':new(component)
|
||||
return
|
||||
require 'lualine.components.special.function_component':new(component)
|
||||
end
|
||||
if type(component[1]) == 'string' then
|
||||
-- load the component
|
||||
|
@ -158,7 +159,8 @@ local function statusline(sections, is_focused)
|
|||
local current_section = status_builder[i]
|
||||
local next_section = status_builder[i + 1] or {}
|
||||
-- For 2nd half we need to show separator before section
|
||||
if current_section.name > 'x' and config.options.section_separators[2] ~= '' then
|
||||
if current_section.name > 'x' and config.options.section_separators[2] ~=
|
||||
'' then
|
||||
local transitional_highlight = highlight.get_transitional_highlights(
|
||||
previous_section.data,
|
||||
current_section.data, true)
|
||||
|
@ -173,7 +175,8 @@ local function statusline(sections, is_focused)
|
|||
table.insert(status, status_builder[i].data)
|
||||
|
||||
-- For 1st half we need to show separator after section
|
||||
if current_section.name < 'c' and config.options.section_separators[1] ~= '' then
|
||||
if current_section.name < 'c' and config.options.section_separators[1] ~=
|
||||
'' then
|
||||
local transitional_highlight = highlight.get_transitional_highlights(
|
||||
current_section.data,
|
||||
next_section.data)
|
||||
|
@ -211,6 +214,15 @@ local function get_extension_sections()
|
|||
end
|
||||
|
||||
local function status_dispatch()
|
||||
-- disable on specific filetypes
|
||||
local current_ft = vim.api.nvim_buf_get_option(
|
||||
vim.fn.winbufnr(vim.g.statusline_winid), 'filetype')
|
||||
for _, ft in pairs(config.options.disabled_filetypes) do
|
||||
if ft == current_ft then
|
||||
vim.wo.statusline = ''
|
||||
return ''
|
||||
end
|
||||
end
|
||||
local extension_sections = get_extension_sections()
|
||||
if vim.g.statusline_winid == vim.fn.win_getid() then
|
||||
local sections = extension_sections.sections
|
||||
|
@ -273,9 +285,7 @@ local function set_statusline()
|
|||
end
|
||||
|
||||
local function setup(user_config)
|
||||
if not user_config then
|
||||
apply_configuration(vim.g.lualine)
|
||||
end
|
||||
if not user_config then apply_configuration(vim.g.lualine) end
|
||||
apply_configuration(user_config)
|
||||
check_single_separator()
|
||||
setup_theme()
|
||||
|
|
Loading…
Reference in New Issue