### Setup Lualine with Default Configuration Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Initialize lualine.nvim with its default settings. This is the most basic way to get lualine working. ```lua require('lualine').setup() ``` -------------------------------- ### Define and Setup Custom Extension Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Define and set up your own custom lualine extensions. This example creates a simple extension for Lua files. ```lua local my_extension = { sections = { lualine_a = {'mode'} }, filetypes = {'lua'} } require('lualine').setup { extensions = { my_extension } } ``` -------------------------------- ### Install Lualine with paq.nvim Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Introduction Install lualine.nvim and nvim-web-devicons using the paq.nvim plugin manager. ```lua require'paq' { 'nvim-lualine/lualine.nvim', 'kyazdani42/nvim-web-devicons' } ``` -------------------------------- ### Install with Lazy.nvim Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Install lualine.nvim using Lazy.nvim, including nvim-web-devicons as a dependency. ```lua { 'nvim-lualine/lualine.nvim', dependencies = { 'nvim-tree/nvim-web-devicons' } } ``` -------------------------------- ### Install with Packer.nvim Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Install lualine.nvim with Packer.nvim, specifying nvim-web-devicons as a required dependency. ```lua use { 'nvim-lualine/lualine.nvim', requires = { 'nvim-tree/nvim-web-devicons', opt = true } } ``` -------------------------------- ### Jump to Buffer Command Examples Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Examples of using the :LualineBuffersJump command to navigate between buffers. ```vim :LualineBuffersJump 2 " Jumps to 2nd buffer in buffers component. :LualineBuffersJump $ " Jumps to last buffer in buffers component. :LualineBuffersJump! 3 " Attempts to jump to 3rd buffer, if it exists. ``` -------------------------------- ### Basic Lualine Setup Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure lualine.nvim in your init.vim using lua heredoc. This sets up the default configuration. ```vim lua << END require('lualine').setup() END ``` -------------------------------- ### Install with vim-plug Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Install lualine.nvim using vim-plug. Optionally include nvim-web-devicons for icon support. ```vim Plug 'nvim-lualine/lualine.nvim' " If you want to have icons in your statusline choose one of these Plug 'nvim-tree/nvim-web-devicons' ``` -------------------------------- ### Install Lualine with Dein.vim Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Introduction Install lualine.nvim and nvim-web-devicons using the Dein.vim plugin manager. ```vim call dein#add('nvim-lualine/lualine.nvim') call dein#add('kyazdani42/nvim-web-devicons') ``` -------------------------------- ### Install with vim.pack Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Use this snippet to install lualine.nvim and nvim-web-devicons using vim.pack. This is for Neovim 0.12 and later. ```vim vim.pack.add({ 'https://github.com/nvim-tree/nvim-web-devicons', 'https://github.com/nvim-lualine/lualine.nvim' }) ``` -------------------------------- ### Install Lualine with VimPlug Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Introduction Install lualine.nvim and nvim-web-devicons using the VimPlug plugin manager. ```vim Plug 'nvim-lualine/lualine.nvim' Plug 'kyazdani42/nvim-web-devicons' ``` -------------------------------- ### Install Lualine with Packer Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Introduction Install lualine.nvim and optionally nvim-web-devicons using the Packer plugin manager. ```lua use { 'nvim-lualine/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } ``` -------------------------------- ### Setup Lualine with a Specific Theme Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure lualine to use a predefined theme. Ensure the theme exists in lualine's theme directory or is provided by an extension. ```lua options = { theme = 'gruvbox' } ``` -------------------------------- ### Rename Tab Command Example Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Example of using the :LualineRenameTab command to set a name for the current tabpage. ```vim :LualineRenameTab Project_K ``` -------------------------------- ### General Component Option: Mode Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the 'mode' component, including enabling icons and specifying icon details. This example shows how to enable icons for the mode component. ```lua sections = { lualine_a = { { 'mode', icons_enabled = true, } } } ``` -------------------------------- ### Get Current Lualine Configuration Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Retrieve the current configuration of lualine. This is useful for inspecting or debugging your setup. ```lua require('lualine').get_config() ``` -------------------------------- ### Configure Tabline as Statusline Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Move the statusline to the tabline by configuring `lualine.tabline` and disabling sections. This is a basic setup. ```lua tabline = { ...... }, sections = {}, inactive_sections = {}, ``` -------------------------------- ### Use Gitsigns.nvim for Diff Info Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Displays Git diff information (added, modified, removed lines) by integrating with gitsigns.nvim. Requires gitsigns.nvim to be installed. ```lua local function diff_source() local gitsigns = vim.b.gitsigns_status_dict if gitsigns then return { added = gitsigns.added, modified = gitsigns.changed, removed = gitsigns.removed } end end require'lualine'.setup { sections = { lualine_b = { {'diff', source = diff_source}, }, } } ``` -------------------------------- ### Use Gitsigns.nvim for Branch Info Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Integrates with gitsigns.nvim to display the current Git branch name in the lualine. Requires gitsigns.nvim to be installed. ```lua lualine_b = { {'b:gitsigns_head', icon = ''}, }, ``` -------------------------------- ### Use Signify for Diff Info Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Displays Git diff information (added, modified, removed lines) by integrating with the signify plugin. Requires signify to be installed. ```lua local function diff_source() if vim.fn.exists('*sy#repo#get_stats') == 1 then local stats = vim.fn['sy#repo#get_stats']() return { added = stats[1], modified = stats[2], removed = stats[3], } end end require'lualine'.setup { sections = { lualine_b = { {'diff', source = diff_source}, }, } } ``` -------------------------------- ### Hide Lualine Completely Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Completely disable lualine for specified places. Call this after setup. `unhide = false` means to hide. ```lua require('lualine').hide({ place = {'statusline', 'tabline', 'winbar'}, unhide = false, -- whether to re-enable lualine again/ }) ``` -------------------------------- ### Use Fugitive Head for Branch Info Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Integrates with vim-fugitive to display the current Git branch name in the lualine. Requires vim-fugitive to be installed. ```lua lualine_b = { {'FugitiveHead', icon = ''}, }, ``` -------------------------------- ### Customize lualine.nvim Theme Colors Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Allows modification of specific color elements within an existing lualine theme. This example changes the background color of the 'c' component in the normal mode for the 'gruvbox' theme. ```lua local custom_gruvbox = require'lualine.themes.gruvbox' -- Change the background of lualine_c section for normal mode custom_gruvbox.normal.c.bg = '#112233' require('lualine').setup { options = { theme = custom_gruvbox }, ... } ``` -------------------------------- ### Define a Custom lualine Theme Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Writing-a-theme This Lua code defines a custom theme for lualine.nvim, specifying colors and styles for various Vim modes (normal, insert, visual, replace, command) and sections (a, b, c). Colors can be defined using hex codes, color names, or cterm colors. Special effects like 'bold' can be applied using the 'gui' field. This example demonstrates the gruvbox theme. ```lua local colors = { black = '#282828', white = '#ebdbb2', red = '#fb4934', green = '#b8bb26', blue = '#83a598', yellow = '#fe8019', gray = '#a89984', darkgray = '#3c3836', lightgray = '#504945', inactivegray = '#7c6f64', } return { normal = { a = {bg = colors.gray, fg = colors.black, gui = 'bold'}, b = {bg = colors.lightgray, fg = colors.white}, c = {bg = colors.darkgray, fg = colors.gray} }, insert = { a = {bg = colors.blue, fg = colors.black, gui = 'bold'}, b = {bg = colors.lightgray, fg = colors.white}, c = {bg = colors.lightgray, fg = colors.white} }, visual = { a = {bg = colors.yellow, fg = colors.black, gui = 'bold'}, b = {bg = colors.lightgray, fg = colors.white}, c = {bg = colors.inactivegray, fg = colors.black} }, replace = { a = {bg = colors.red, fg = colors.black, gui = 'bold'}, b = {bg = colors.lightgray, fg = colors.white}, c = {bg = colors.black, fg = colors.white} }, command = { a = {bg = colors.green, fg = colors.black, gui = 'bold'}, b = {bg = colors.lightgray, fg = colors.white}, c = {bg = colors.inactivegray, fg = colors.black} }, inactive = { a = {bg = colors.darkgray, fg = colors.gray, gui = 'bold'}, b = {bg = colors.darkgray, fg = colors.gray}, c = {bg = colors.darkgray, fg = colors.gray} } } ``` ```lua require('lualine').setup {options = {theme = gruvbox}} ``` -------------------------------- ### Configure Winbar Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Set up the winbar for active windows to display the filename. This configuration is for Neovim 0.8+ and treats the winbar similarly to a statusline. ```lua winbar = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } ``` -------------------------------- ### Tabline Configuration with Filename and Branch Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the tabline to display the current branch and filename. ```lua tabline = { lualine_a = {}, lualine_b = {'branch'}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } ``` -------------------------------- ### Winbar Configuration Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the winbar to display the filename for both active and inactive windows. ```lua winbar = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } inactive_winbar = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } ``` -------------------------------- ### Configure Tabline with Branch and Filename Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Set up the tabline to display the current branch and filename. This configuration uses standard lualine components for the tabline. ```lua tabline = { lualine_a = {}, lualine_b = {'branch'}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } ``` -------------------------------- ### Tabline Configuration with Buffers and Tabs Components Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the tabline to use the 'buffers' and 'tabs' components for a traditional tab experience. ```lua tabline = { lualine_a = {'buffers'}, lualine_b = {'branch'}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {'tabs'} } ``` -------------------------------- ### Add Vim Function Component to Lualine Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Use a Vim function as a component in lualine. The function will be called by lualine to get its display value. ```lua sections = { lualine_a = {'FugitiveHead'} } ``` -------------------------------- ### Configure Windows Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the 'windows' component for the statusline. Options control filename display, modification status, window indexing, maximum width, filetype-specific names, disabled buffer types, active window colors, and more. ```lua sections = { lualine_a = { { 'windows', show_filename_only = true, -- Shows shortened relative path when set to false. show_modified_status = true, -- Shows indicator when the window is modified. mode = 0, -- 0: Shows window name -- 1: Shows window index -- 2: Shows window name + window index max_length = vim.o.columns * 2 / 3, -- Maximum width of windows component, -- it can also be a function that returns -- the value of `max_length` dynamically. filetype_names = { TelescopePrompt = 'Telescope', dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', alpha = 'Alpha' }, -- Shows specific window name for that filetype ( { `filetype` = `window_name`, ... } ) disabled_buftypes = { 'quickfix', 'prompt' }, -- Hide a window if its buffer's type is disabled -- Automatically updates active window color to match color of other components (will be overidden if buffers_color is set) use_mode_colors = false, windows_color = { -- Same values as the general color option can be used here. active = 'lualine_{section}_normal', -- Color for active window. inactive = 'lualine_{section}_inactive', -- Color for inactive window. }, } } } ``` -------------------------------- ### Configure Filename Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize how the filename and its path are displayed, including status indicators and shortening. ```lua sections = { lualine_a = { { 'filename', file_status = true, -- Displays file status (readonly status, modified status) newfile_status = false, -- Display new file status (new file means no write after created) path = 0, -- 0: Just the filename -- 1: Relative path -- 2: Absolute path -- 3: Absolute path, with tilde as the home directory -- 4: Filename and parent dir, with tilde as the home directory shorting_target = 40, -- Shortens path to leave 40 spaces in the window -- for other components. (terrible name, any suggestions?) -- It can also be a function that returns -- the value of `shorting_target` dynamically. symbols = { modified = '[+]', -- Text to show when the file is modified. readonly = '[-]', -- Text to show when the file is non-modifiable or readonly. unnamed = '[No Name]', -- Text to show for unnamed buffers. newfile = '[New]', -- Text to show for newly created file before first write } } } } ``` -------------------------------- ### Configure Fileformat Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Customize the symbols displayed for different file formats (Unix, DOS, Mac) in the fileformat component. ```lua sections = { lualine_a = { { 'fileformat', symbols = { unix = '', dos = '', mac = '', } } } } ``` -------------------------------- ### Configure Inactive Winbar Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Set up the winbar for inactive windows to display the filename. This configuration allows for distinct winbar appearances between active and inactive windows. ```lua inactive_winbar = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {}, lualine_y = {}, lualine_z = {} } ``` -------------------------------- ### Configure Encoding Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Set options for the encoding component, specifically to show Byte-Order Marks. ```lua sections = { lualine_a = { { 'encoding', -- Show '[BOM]' when the file has a byte-order mark show_bomb = false, } } } ``` -------------------------------- ### Configure Filetype Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Control the display of the filetype component, including colorization and icon usage. ```lua sections = { lualine_a = { { 'filetype', colored = true, -- Displays filetype icon in color if set to true icon_only = false, -- Display only an icon for filetype icon = { align = 'right' }, -- Display filetype icon on the right hand side -- icon = {'X', align='right'} -- Icon string ^ in table is ignored in filetype component } } } ``` -------------------------------- ### Configure Fileformat Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the symbols used to represent different file formats (Unix, DOS, Mac) in the status line. ```lua sections = { lualine_a = { { 'fileformat', symbols = { unix = '', -- e712 dos = '', -- e70f mac = '', -- e711 } } } } ``` -------------------------------- ### Configure Datetime Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Set the style for the datetime component. Available styles include 'default', 'us', 'uk', 'iso', or a custom format string. ```lua sections = { lualine_a = { { 'datetime', style = 'default' } } } ``` -------------------------------- ### Buffers Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the 'buffers' component. Options include showing only the filename, hiding the extension, displaying modification status, and choosing between buffer name or index. ```lua 'buffers', show_filename_only = true, -- Shows shortened relative path when set to false. hide_filename_extension = false, -- Hide filename extension when set to true. show_modified_status = true, -- Shows indicator when the buffer is modified. mode = 0, -- 0: Shows buffer name -- 1: Shows buffer index ``` -------------------------------- ### Windows Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the windows component to control filename display, modified status, mode, and maximum length. ```lua sections = { lualine_a = { { 'windows', show_filename_only = true, show_modified_status = true, mode = 0, max_length = vim.o.columns * 2 / 3, filetype_names = { TelescopePrompt = 'Telescope', dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', alpha = 'Alpha' } } } } ``` -------------------------------- ### Configure Filename Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Control the display of file status (modified, new file) and path format (filename only, relative path) for the filename component. ```lua sections = { lualine_a = { { 'filename', file_status = true, newfile_status = false, path = 0, } } } ``` -------------------------------- ### General Component Options in Lualine.nvim Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Configures general behavior for lualine.nvim components, including icons, separators, conditions, colors, and formatting. Use these options to customize the appearance and functionality of any component. ```lua sections = { lualine_a = { { 'mode', icons_enabled = true, -- Enables the display of icons alongside the component. -- Defines the icon to be displayed in front of the component. -- Can be string|table -- As table it must contain the icon as first entry and can use -- color option to custom color the icon. Example: -- {'branch', icon = ''} / {'branch', icon = {'', color={fg='green'}}} -- icon position can also be set to the right side from table. Example: -- {'branch', icon = {'', align='right', color={fg='green'}}} icon = nil, separator = nil, -- Determines what separator to use for the component. -- Note: -- When a string is provided it's treated as component_separator. -- When a table is provided it's treated as section_separator. -- Passing an empty string disables the separator. -- -- These options can be used to set colored separators -- around a component. -- -- The options need to be set as such: -- separator = { left = '', right = ''} -- -- Where left will be placed on left side of component, -- and right will be placed on its right. -- cond = nil, -- Condition function, the component is loaded when the function returns `true`. draw_empty = false, -- Whether to draw component even if it's empty. -- Might be useful if you want just the separator. -- Defines a custom color for the component: -- -- 'highlight_group_name' | { fg = '#rrggbb'|cterm_value(0-255)|'color_name(red)', bg= '#rrggbb', gui='style' } | function -- Note: -- '|' is synonymous with 'or', meaning a different acceptable format for that placeholder. -- color function has to return one of other color types ('highlight_group_name' | { fg = '#rrggbb'|cterm_value(0-255)|'color_name(red)', bg= '#rrggbb', gui='style' }) -- color functions can be used to have different colors based on state as shown below. -- -- Examples: -- color = { fg = '#ffaa88', bg = 'grey', gui='italic,bold' }, -- color = { fg = 204 } -- When fg/bg are omitted, they default to the your theme's fg/bg. -- color = 'WarningMsg' -- Highlight groups can also be used. -- color = function(section) -- return { fg = vim.bo.modified and '#aa3355' or '#33aa88' } -- end, color = nil, -- The default is your theme's color for that section and mode. -- Specify what type a component is, if omitted, lualine will guess it for you. -- -- Available types are: -- [format: type_name(example)], mod(branch/filename), -- stl(%f/%m), var(g:coc_status/bo:modifiable), -- lua_expr(lua expressions), vim_fun(viml function name) -- -- Note: -- lua_expr is short for lua-expression and vim_fun is short for vim-function. type = nil, padding = 1, -- Adds padding to the left and right of components. -- Padding can be specified to left or right independently, e.g.: -- padding = { left = left_padding, right = right_padding } fmt = nil, -- Format function, formats the component's output. -- This function receives two arguments: -- - string that is going to be displayed and -- that can be changed, enhanced and etc. -- - context object with information you might -- need. E.g. tabnr if used with tabs. on_click = nil, -- takes a function that is called when component is clicked with mouse. -- the function receives several arguments -- - number of clicks in case of multiple clicks -- - mouse button used (l(left)/r(right)/m(middle)/...) -- - modifiers pressed (s(shift)/c(ctrl)/a(alt)/m(meta)... } } } ``` -------------------------------- ### Configure Buffers Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the display of buffer information in the status line. Options control filename display, modification status, buffer mode, maximum length, filetype aliases, and colors. ```lua sections = { lualine_a = { { 'buffers', show_filename_only = true, -- Shows shortened relative path when set to false. hide_filename_extension = false, -- Hide filename extension when set to true. show_modified_status = true, -- Shows indicator when the buffer is modified. mode = 0, -- 0: Shows buffer name -- 1: Shows buffer index -- 2: Shows buffer name + buffer index -- 3: Shows buffer number -- 4: Shows buffer name + buffer number max_length = vim.o.columns * 2 / 3, -- Maximum width of buffers component, -- it can also be a function that returns -- the value of `max_length` dynamically. filetype_names = { TelescopePrompt = 'Telescope', dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', alpha = 'Alpha' }, -- Shows specific buffer name for that filetype ( { `filetype` = `buffer_name`, ... } ) -- Automatically updates active buffer color to match color of other components (will be overidden if buffers_color is set) use_mode_colors = false, buffers_color = { -- Same values as the general color option can be used here. active = 'lualine_{section}_normal', -- Color for active buffer. inactive = 'lualine_{section}_inactive', -- Color for inactive buffer. }, symbols = { modified = ' ●', -- Text to show when the buffer is modified alternate_file = '#', -- Text to show to identify the alternate file directory = '', -- Text to show when the buffer is a directory }, } } } ``` -------------------------------- ### LSP Status Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the lsp_status component with custom icons, symbols, and ignored LSP servers. ```lua sections = { lualine_a = { { 'lsp_status', icon = '', -- f013 symbols = { -- Standard unicode symbols to cycle through for LSP progress: spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, -- Standard unicode symbol for when LSP is done: done = '✓', -- Delimiter inserted between LSP names: separator = ' ', }, -- List of LSP names to ignore (e.g., `null-ls`): ignore_lsp = {}, -- Display the LSP name show_name = true, } } } ``` -------------------------------- ### Filetype Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Customize the display of the filetype component. Options include enabling color, showing only the icon, and aligning the icon. ```lua sections = { lualine_a = { { 'filetype', colored = true, icon_only = false, icon = { align = 'right' }, } } } ``` -------------------------------- ### Load Extensions Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Load extensions to change statusline appearance for specific filetypes. Extensions are not loaded by default for performance. ```lua extensions = {'quickfix'} ``` -------------------------------- ### Encoding Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure the encoding component to show Byte-Order Mark (BOM) information. ```lua sections = { lualine_a = { { 'encoding', show_bomb = false, } } } ``` -------------------------------- ### Configure Diagnostics Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the display of diagnostic information, including sources, severity levels, and colors. Options control which sources are monitored and how diagnostics are presented. ```lua sections = { lualine_a = { { 'diagnostics', -- Table of diagnostic sources, available sources are: -- 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic', 'coc', 'ale', 'vim_lsp'. -- or a function that returns a table as such: -- { error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt } sources = { 'nvim_diagnostic', 'coc' }, -- Displays diagnostics for the defined severity types sections = { 'error', 'warn', 'info', 'hint' }, diagnostics_color = { -- Same values as the general color option can be used here. error = 'DiagnosticError', -- Changes diagnostics' error color. warn = 'DiagnosticWarn', -- Changes diagnostics' warn color. info = 'DiagnosticInfo', -- Changes diagnostics' info color. hint = 'DiagnosticHint', -- Changes diagnostics' hint color. }, symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}, colored = true, -- Displays diagnostics status in color if set to true. update_in_insert = false, -- Update diagnostics in insert mode. always_visible = false, -- Show diagnostics even if there are none. } } } ``` -------------------------------- ### File Path Shortening Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure how file paths are displayed in Lualine. Options include shortening targets, symbols for modified, readonly, unnamed, and new files. ```lua shorting_target = 40, symbols = { modified = '[+]', readonly = '[-]', unnamed = '[No Name]', newfile = '[New]', } ``` -------------------------------- ### Configure Datetime Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Set the style for the datetime component in the status line. Supports default, US, UK, ISO, or custom format strings. ```lua sections = { lualine_a = { { 'datetime', -- options: default, us, uk, iso, or your own format string ("%H:%M", etc..) style = 'default' } } } ``` -------------------------------- ### Lualine Plugin Folder Structure Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Plugins This is the standard directory layout for a lualine.nvim plugin. Include only the folders necessary for your plugin's functionality. ```directory . ├── README.md # Readme for your awesome plugin. └── lua └── lualine ├── components # This folder contains the components you want to provide. │ ├── component1.lua │ └── component2 # you can have a module with multiple files too │ ├── init.lua │ └── component2_helper.lua ├── extensions # This folder contains the extensions you want to provide. │ ├── extensions1.lua │ └── extensions2 # you can have a module with multiple files too │ ├── init.lua │ └── extension2_helper.lua └── themes # This folder contains the themes you want to provide. ├── theme1.lua └── theme2 # you can have a module with multiple files too ├── init.lua └── theme2_helper.lua ``` -------------------------------- ### Search Count Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Set options for the search count component, including the maximum count and timeout. ```lua sections = { lualine_a = { { 'searchcount', maxcount = 999, timeout = 500, } } } ``` -------------------------------- ### Global Options Configuration Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure global behavior for Lualine, such as theme, separators, disabled filetypes, and global statusline settings. These options serve as defaults for component-level configurations. ```lua options = { theme = 'auto', component_separators = { left = '', right = '' }, section_separators = { left = '', right = '' }, disabled_filetypes = { statusline = {}, winbar = {}, }, ignore_focus = {}, always_divide_middle = true, always_show_tabline = true, globalstatus = false, refresh = { statusline = 100, tabline = 100, winbar = 100, refresh_time = 16, events = { 'WinEnter', 'BufEnter', 'BufWritePost', 'SessionLoadPost', 'FileChangedShellPost', 'VimResized', 'Filetype', 'CursorMoved', 'CursorMovedI', 'ModeChanged', } } } ``` -------------------------------- ### Configure Lualine Refresh Interval Source: https://github.com/nvim-lualine/lualine.nvim/wiki/FAQ Adjust the update frequency for statusline, tabline, and winbar in milliseconds. Default is 1000ms. ```lua require('lualine').setup({ options = { refresh = { statusline = 200, -- Note these are in mili second and default is 1000 tabline = 500, winbar = 300, } } }) ``` -------------------------------- ### Configure Diagnostics Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Customize the diagnostics component by specifying sources, severity sections, colors, symbols, and update behavior. It can also be configured to always be visible. ```lua sections = { lualine_a = { { 'diagnostics', sources = { 'nvim_diagnostic', 'coc' }, sections = { 'error', 'warn', 'info', 'hint' }, diagnostics_color = { error = 'DiagnosticError', warn = 'DiagnosticWarn', info = 'DiagnosticInfo', hint = 'DiagnosticHint', }, symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}, colored = true, update_in_insert = false, always_visible = false, } } } ``` -------------------------------- ### Apply Local Component Formatting Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Override global component formatting options for specific components. This allows for unique formatting on a per-component basis. ```lua require('lualine').setup { options = { fmt = string.lower }, sections = { lualine_a = { { 'mode', fmt = function(str) return str:sub(1,1) end } }, lualine_b = {'branch'} } } ``` -------------------------------- ### Default Lualine Configuration Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt This is the default configuration for lualine.nvim, showing options for icons, themes, separators, and section components. ```lua require('lualine').setup { options = { icons_enabled = true, theme = 'auto', component_separators = { left = '', right = ''}, section_separators = { left = '', right = ''}, disabled_filetypes = { statusline = {}, winbar = {}, }, ignore_focus = {}, always_divide_middle = true, always_show_tabline = true, globalstatus = false, refresh = { statusline = 1000, tabline = 1000, winbar = 1000, refresh_time = 16, -- ~60fps events = { 'WinEnter', 'BufEnter', 'BufWritePost', 'SessionLoadPost', 'FileChangedShellPost', 'VimResized', 'Filetype', 'CursorMoved', 'CursorMovedI', 'ModeChanged', }, } }, sections = { lualine_a = {'mode'}, lualine_b = {'branch', 'diff', 'diagnostics'}, lualine_c = {'filename'}, lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_y = {'progress'}, lualine_z = {'location'} }, inactive_sections = { ``` -------------------------------- ### Truncate Components in Small Windows Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Provides a function to truncate or hide components based on window width. Useful for optimizing display on smaller screens. ```lua --- @param trunc_width number trunctates component when screen width is less then trunc_width --- @param trunc_len number truncates component to trunc_len number of chars --- @param hide_width number hides component when window width is smaller then hide_width --- @param no_ellipsis boolean whether to disable adding '...' at end after truncation --- return function that can format the component accordingly local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis) return function(str) local win_width = vim.fn.winwidth(0) if hide_width and win_width < hide_width then return '' elseif trunc_width and trunc_len and win_width < trunc_width and #str > trunc_len then return str:sub(1, trunc_len) .. (no_ellipsis and '' or '...') end return str end end require'lualine'.setup { lualine_a = { {'mode', fmt=trunc(80, 4, nil, true)}, {'filename', fmt=trunc(90, 30, 50)}, {function() return require'lsp-status'.status() end, fmt=trunc(120, 20, 60)} } } ``` -------------------------------- ### Jump to Buffer by Index Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Use the `:LualineBuffersJump` command to navigate to a specific buffer based on its index in the buffers component. The `!` modifier can be used to ignore errors for non-existent buffer indices. ```vim :LualineBuffersJump 2 " Jumps to 2nd buffer in buffers component. :LualineBuffersJump $ " Jumps to last buffer in buffers component. :LualineBuffersJump! 3 " Attempts to jump to 3rd buffer, if it exists. ``` -------------------------------- ### Force Lualine Refresh with Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Force lualine to refresh immediately with specified scope and place. Use `force = true` to bypass the refresh queue. ```lua require('lualine').refresh({ force = true, -- do an immidiate refresh scope = 'tabpage', -- scope of refresh all/tabpage/window place = { 'statusline', 'winbar', 'tabline' }, -- lualine segment ro refresh. }) ``` -------------------------------- ### Configure Tabs Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the display of tabs, including length, path representation, and modified status. ```lua sections = { lualine_a = { { 'tabs', tab_max_length = 40, -- Maximum width of each tab. The content will be shorten dynamically (example: apple/orange -> a/orange) max_length = vim.o.columns / 3, -- Maximum width of tabs component. -- Note: -- It can also be a function that returns -- the value of `max_length` dynamically. mode = 0, -- 0: Shows tab_nr -- 1: Shows tab_name -- 2: Shows tab_nr + tab_name path = 0, -- 0: just shows the filename -- 1: shows the relative path and shorten $HOME to ~ -- 2: shows the full path -- 3: shows the full path and shorten $HOME to ~ -- Automatically updates active tab color to match color of other components (will be overidden if buffers_color is set) use_mode_colors = false, tabs_color = { -- Same values as the general color option can be used here. active = 'lualine_{section}_normal', -- Color for active tab. inactive = 'lualine_{section}_inactive', -- Color for inactive tab. }, show_modified_status = true, -- Shows a symbol next to the tab name if the file has been modified. symbols = { modified = '[+]', -- Text to show when the file is modified. }, fmt = function(name, context) -- Show + if buffer is modified in tab local buflist = vim.fn.tabpagebuflist(context.tabnr) local winnr = vim.fn.tabpagewinnr(context.tabnr) local bufnr = buflist[winnr] local mod = vim.fn.getbufvar(bufnr, '&mod') return name .. (mod == 1 and ' +' or '') end } } } ``` -------------------------------- ### Component Format Function Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Define a format function to customize the output of a component. This function receives the string to be displayed and a context object. ```lua fmt = nil, -- Format function, formats the component's output. -- This function receives two arguments: -- - string that is going to be displayed and -- that can be changed, enhanced and etc. -- - context object with information you might -- need. E.g. tabnr if used with tabs. ``` -------------------------------- ### Configure Buffers Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Customize the display of buffer information, including maximum length, filetype-specific names, and colors for active/inactive buffers. It also defines symbols for modified, alternate, and directory buffers. ```lua buffers = { max_length = vim.o.columns * 2 / 3, filetype_names = { TelescopePrompt = 'Telescope', dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', alpha = 'Alpha' }, use_mode_colors = false, buffers_color = { active = 'lualine_{section}_normal', inactive = 'lualine_{section}_inactive', }, symbols = { modified = ' ●', alternate_file = '#', directory = '', }, } ``` -------------------------------- ### Component Separator Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Configure separators for components. A string sets the component separator, while a table defines left and right separators for a section. An empty string disables separators. ```lua separator = nil, -- Determines what separator to use for the component. -- Note: -- When a string is provided it's treated as component_separator. -- When a table is provided it's treated as section_separator. -- Passing an empty string disables the separator. -- -- These options can be used to set colored separators -- around a component. -- -- The options need to be set as such: -- separator = { left = '', right = ''} -- -- Where left will be placed on left side of component, -- and right will be placed on its right. ``` -------------------------------- ### Component Padding Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Add padding to the left and right of components. Padding can be specified independently for the left and right sides. ```lua padding = 1, -- Adds padding to the left and right of components. -- Padding can be specified to left or right independently, e.g.: -- padding = { left = left_padding, right = right_padding } ``` -------------------------------- ### Configure Tabline as Statusline Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Move your statusline to the tabline by configuring lualine.tabline and disabling sections. This is useful for a unified tab and status display. ```lua tabline = { ...... }, sections = {}, inactive_sections = {}, ``` -------------------------------- ### Display Fileformat as CRLF Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets Configures the 'fileformat' component to display 'CRLF' for DOS file formats instead of icons or default text. Ensures consistent display across different operating systems. ```lua require'lualine'.setup { sections = { lualine_x = { { 'fileformat', icons_enabled = true, symbols = { unix = 'LF', dos = 'CRLF', mac = 'CR', }, }, }, }, } ``` -------------------------------- ### Configure Diff Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt Customize the diff component's appearance with colored status, specific colors for added, modified, and removed lines, and custom symbols. A function can also be provided as a data source. ```lua sections = { lualine_a = { { 'diff', colored = true, diff_color = { added = 'LuaLineDiffAdd', modified = 'LuaLineDiffChange', removed = 'LuaLineDiffDelete', }, symbols = {added = '+', modified = '~', removed = '-'}, source = nil, } } } ``` -------------------------------- ### Configure Diff Component Options Source: https://github.com/nvim-lualine/lualine.nvim/blob/master/README.md Customize the display of diff status in the status line. Options control whether the diff is colored, define custom colors for added, modified, and removed lines, and set symbols. ```lua sections = { lualine_a = { { 'diff', colored = true, -- Displays a colored diff status if set to true diff_color = { -- Same color values as the general color option can be used here. added = 'LuaLineDiffAdd', -- Changes the diff's added color modified = 'LuaLineDiffChange', -- Changes the diff's modified color removed = 'LuaLineDiffDelete', -- Changes the diff's removed color you }, symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the symbols used by the diff. source = nil, -- A function that works as a data source for diff. -- It must return a table as such: -- { added = add_count, modified = modified_count, removed = removed_count } -- or nil on failure. count <= 0 won't be displayed. } } } ```