diff --git a/README.md b/README.md
index be48181..0390327 100644
--- a/README.md
+++ b/README.md
@@ -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
`color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}`
The fields of color table are optional and default to theme
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' : {
diff --git a/doc/lualine.txt b/doc/lualine.txt
index 0771629..b91b928 100644
--- a/doc/lualine.txt
+++ b/doc/lualine.txt
@@ -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' : {
diff --git a/lua/lualine/defaults.lua b/lua/lualine/defaults.lua
index 12fe7b5..33763f7 100644
--- a/lua/lualine/defaults.lua
+++ b/lua/lualine/defaults.lua
@@ -4,7 +4,8 @@ M.options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = {'', ''},
- section_separators = {'', ''}
+ section_separators = {'', ''},
+ disabled_filetypes = {},
}
M.sections = {
diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua
index 1d76875..3c18eab 100644
--- a/lua/lualine/init.lua
+++ b/lua/lualine/init.lua
@@ -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()