diff --git a/README.md b/README.md index 05db4ac..959ba76 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Lualine has sections as shown below. Each sections holds it's components e.g. current vim's mode. -
Configuring from `.vim` file +
Configuring lualine in init.vim All the examples below are in lua. You can use the same examples in `.vim` file by wrapping them in lua heredoc like this: @@ -332,26 +332,40 @@ shown . On the other hand branch will be formatted with global formatter
Global options +These are `options` that are used in options table. +They set behavior of lualine. + +Values set here are treated as default for other options +that work in component level. + +for example even though `icons_enabled` is a general component option. +you can set `icons_enabled` to `false` and icons will be disabled on all +component. You can still overwrite defaults set in option table by specifying +the option value in component. + ```lua options = { - icons_enabled = true, -- displays icons in alongside component - padding = 1, -- adds padding to the left and right of components - -- padding can be specified to left or right separately like - -- padding = { left = left_padding, right = right_padding } - fmt = nil -- fmt function, formats component's output + theme = 'auto', -- lualine theme + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {}, -- filetypes to diable lualine on } ```
-Local options +General component options + +These are options that control behavior at component level +and are available for all components. ```lua sections = { lualine_a = { { 'mode', + icons_enabled = true, -- displays icons in alongside component icon = nil, -- displays icon in front of the component separator = nil, -- Determines what separator to use for the component. -- when a string is given it's treated as component_separator. @@ -375,6 +389,10 @@ sections = { -- luae(lua expressions), vimf(viml function name) -- luae is short for lua-expression and vimf is short fror vim-function type = nil, + padding = 1, -- adds padding to the left and right of components + -- padding can be specified to left or right separately like + -- padding = { left = left_padding, right = right_padding } + fmt = nil, -- format function, formats component's output } } } @@ -383,7 +401,11 @@ sections = {
-Component specific local options +Component specific options + +These are options that are available on specific components. +For example you have option on `diagnostics` component to +specify what your diagnostic sources will be. #### buffers component options @@ -422,7 +444,7 @@ sections = { -- 'nvim_lsp', 'nvim', 'coc', 'ale', 'vim_lsp' -- Or a function that returns a table like -- {error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt} - sources = {}, + sources = {'nvim_lsp', 'coc'}, -- displays diagnostics from defined severity sections = {'error', 'warn', 'info', 'hint'}, -- all colors are in format #rrggbb diff --git a/doc/lualine.txt b/doc/lualine.txt index 2efc935..c8f7e45 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -82,7 +82,7 @@ Lualine has sections as shown below. Each sections holds it’s components e.g. current vim’s mode. -Configuring from `.vim` file +Configuring lualine in init.vim All the examples below are in lua. You can use the same examples in `.vim` file by wrapping them in lua heredoc like this: @@ -313,24 +313,40 @@ shown. On the other hand branch will be formatted with global formatter Global options ~ +Available options These are `options` that are used in + options table. They set behavior of + lualine. + + +Values set here are treated as default for other options that work in component +level. + +for example even though `icons_enabled` is a general component option. you can +set `icons_enabled` to `false` and icons will be disabled on all component. You +can still overwrite defaults set in option table by specifying the option value +in component. + > options = { - icons_enabled = true, -- displays icons in alongside component - padding = 1, -- adds padding to the left and right of components - -- padding can be specified to left or right separately like - -- padding = { left = left_padding, right = right_padding } - fmt = nil -- fmt function, formats component's output + theme = 'auto', -- lualine theme + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {}, -- filetypes to diable lualine on } < -Local options ~ +General component options ~ + +These are options that control behavior at component level and are available +for all components. > sections = { lualine_a = { { 'mode', + icons_enabled = true, -- displays icons in alongside component icon = nil, -- displays icon in front of the component separator = nil, -- Determines what separator to use for the component. -- when a string is given it's treated as component_separator. @@ -354,13 +370,21 @@ Local options ~ -- luae(lua expressions), vimf(viml function name) -- luae is short for lua-expression and vimf is short fror vim-function type = nil, + padding = 1, -- adds padding to the left and right of components + -- padding can be specified to left or right separately like + -- padding = { left = left_padding, right = right_padding } + fmt = nil, -- format function, formats component's output } } } < -Component specific local options ~ +Component specific options ~ + +These are options that are available on specific components. For example you +have option on `diagnostics` component to specify what your diagnostic sources +will be. *lualine-buffers-component-options* @@ -400,7 +424,7 @@ Component specific local options ~ -- 'nvim_lsp', 'nvim', 'coc', 'ale', 'vim_lsp' -- Or a function that returns a table like -- {error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt} - sources = {}, + sources = {'nvim_lsp', 'coc'}, -- displays diagnostics from defined severity sections = {'error', 'warn', 'info', 'hint'}, -- all colors are in format #rrggbb diff --git a/lua/lualine/components/buffers.lua b/lua/lualine/components/buffers.lua index 8bc00bc..1fd9c97 100644 --- a/lua/lualine/components/buffers.lua +++ b/lua/lualine/components/buffers.lua @@ -14,6 +14,10 @@ local default_options = { fzf = 'FZF', alpha = 'Alpha', }, + buffers_color = { + active = nil, + inactive = nil, + }, } local function get_hl(section, is_active) @@ -42,13 +46,11 @@ end function Buffer:get_props() self.file = vim.fn.bufname(self.bufnr) - self.filepath = vim.fn.expand('#' .. self.bufnr .. ':p:~') self.buftype = vim.api.nvim_buf_get_option(self.bufnr, 'buftype') self.filetype = vim.api.nvim_buf_get_option(self.bufnr, 'filetype') local modified = self.options.show_modified_status and vim.api.nvim_buf_get_option(self.bufnr, 'modified') local modified_icon = self.options.icons_enabled and ' ' or ' +' self.modified_icon = modified and modified_icon or '' - self.visible = vim.fn.bufwinid(self.bufnr) ~= -1 self.icon = '' if self.options.icons_enabled then local dev diff --git a/lua/lualine/components/diagnostics.lua b/lua/lualine/components/diagnostics.lua index 6f85b91..a8f915b 100644 --- a/lua/lualine/components/diagnostics.lua +++ b/lua/lualine/components/diagnostics.lua @@ -49,7 +49,7 @@ local default_symbols = { local default_options = { colored = true, update_in_insert = false, - sources = nil, + sources = { 'nvim_lsp', 'coc' }, sections = { 'error', 'warn', 'info', 'hint' }, diagnostics_color = { error = { @@ -122,7 +122,7 @@ Diagnostics.new = function(self, options, child) end -- Error out no source - if new_diagnostics.options.sources == nil then + if #new_diagnostics.options.sources < 1 then print 'no sources for diagnostics configured' return '' end diff --git a/lua/lualine/components/tabs.lua b/lua/lualine/components/tabs.lua index b563f01..2404860 100644 --- a/lua/lualine/components/tabs.lua +++ b/lua/lualine/components/tabs.lua @@ -6,6 +6,10 @@ local highlight = require 'lualine.highlight' local default_options = { max_length = 0, mode = 0, + tabs_color = { + active = nil, + inactive = nil, + }, } local function get_hl(section, is_active)