Debian Codegraph @

README.md

raw
1 # lualine.nvim
2
3 <!-- panvimdoc-ignore-start -->
4
5 ![code size](https://img.shields.io/github/languages/code-size/nvim-lualine/lualine.nvim?style=flat-square)
6 ![license](https://img.shields.io/github/license/nvim-lualine/lualine.nvim?style=flat-square)
7
8 <!-- panvimdoc-ignore-end -->
9
10 A blazing fast and easy to configure Neovim statusline written in Lua.
11
12 `lualine.nvim` requires Neovim >= 0.7.
13
14 For previous versions of neovim please use compatability tags for example
15 compat-nvim-0.5
16
17 ## Contributing
18
19 Feel free to create an issue/PR if you want to see anything else implemented.
20 If you have some question or need help with configuration, start a [discussion](https://github.com/nvim-lualine/lualine.nvim/discussions).
21
22 Please read [CONTRIBUTING.md](./CONTRIBUTING.md) before opening a PR.
23 You can also help with documentation in the [wiki](https://github.com/nvim-lualine/lualine.nvim/wiki).
24
25 <!-- panvimdoc-ignore-start -->
26
27 ## Screenshots
28
29 Here is a preview of what lualine can look like.
30
31 <p>
32 <img width='700' src='https://user-images.githubusercontent.com/41551030/108650373-bb025580-74bf-11eb-8682-2c09321dd18e.png'/>
33 <img width='700' src='https://user-images.githubusercontent.com/41551030/108650377-bd64af80-74bf-11eb-9c55-fbfc51b39fe8.png'/>
34 <img width='700' src='https://user-images.githubusercontent.com/41551030/108650378-be95dc80-74bf-11eb-9718-82b242ecdd54.png'/>
35 <img width='700' src='https://user-images.githubusercontent.com/41551030/108650381-bfc70980-74bf-11eb-9245-85c48f0f154a.png'/>
36 <img width='700' src='https://user-images.githubusercontent.com/41551030/103467925-32372b00-4d54-11eb-88d6-6d39c46854d8.png'/>
37 </p>
38
39 Screenshots of all available themes are listed in [THEMES.md](./THEMES.md)
40
41 For those who want to break the norms, you can create custom looks for lualine.
42
43 **Example** :
44
45 - [evil_lualine](examples/evil_lualine.lua)
46 <img width='700' src='https://user-images.githubusercontent.com/13149513/113875129-4453ba00-97d8-11eb-8f21-94a9ef565db3.png'/>
47 - [slanted-gaps](examples/slanted-gaps.lua)
48 <img width='700' src='https://user-images.githubusercontent.com/13149513/143395518-f6d6f748-c1ca-491b-9dab-246d0a8cf23f.png'/>
49 - [bubbles](examples/bubbles.lua)
50 <img width='700' src='https://user-images.githubusercontent.com/20235646/131350468-fc556196-5f46-4bfe-a72e-960f6a58db2c.png'/>
51 - [cosmicink](examples/cosmicink.lua)
52 <img width='700' src='https://github.com/user-attachments/assets/c8d3e4ba-4997-42e9-a1bb-d5e2a444bbfd'/>
53
54 <!-- panvimdoc-ignore-end -->
55
56 ## Performance compared to other plugins
57
58 Unlike other statusline plugins, lualine loads only the components you specify, and nothing else.
59
60 Startup time performance measured with an amazing plugin [dstein64/vim-startuptime](https://github.com/dstein64/vim-startuptime)
61
62 Times are measured with a clean `init.vim` with only `vim-startuptime`,
63 `vim-plug` and given statusline plugin installed.
64 In control just `vim-startuptime` and`vim-plug` is installed.
65 And measured time is complete startuptime of vim not time spent
66 on specific plugin. These numbers are the average of 20 runs.
67
68 | control | lualine | lightline | airline |
69 | :-----: | :-----: | :-------: | :-----: |
70 | 17.2 ms | 24.8 ms | 25.5 ms | 79.9 ms |
71
72 Last Updated On: 18-04-2022
73
74 ## Installation
75
76 ### [vim.pack](https://neovim.io/doc/user/pack/#vim.pack) (Only for neovim 0.12)
77
78 ```lua
79 vim.pack.add({
80 'https://github.com/nvim-tree/nvim-web-devicons',
81 'https://github.com/nvim-lualine/lualine.nvim'
82 })
83 ```
84 ### [vim-plug](https://github.com/junegunn/vim-plug)
85
86 ```vim
87 Plug 'nvim-lualine/lualine.nvim'
88 " If you want to have icons in your statusline choose one of these
89 Plug 'nvim-tree/nvim-web-devicons'
90 ```
91
92 ### [packer.nvim](https://github.com/wbthomason/packer.nvim)
93
94 ```lua
95 use {
96 'nvim-lualine/lualine.nvim',
97 requires = { 'nvim-tree/nvim-web-devicons', opt = true }
98 }
99 ```
100
101 ### [lazy.nvim](https://github.com/folke/lazy.nvim)
102
103 ```lua
104 {
105 'nvim-lualine/lualine.nvim',
106 dependencies = { 'nvim-tree/nvim-web-devicons' }
107 }
108 ```
109
110 You'll also need to have a patched font if you want icons.
111
112 ## Usage and customization
113
114 Lualine has sections as shown below.
115
116 ```text
117 +-------------------------------------------------+
118 | A | B | C X | Y | Z |
119 +-------------------------------------------------+
120 ```
121
122 Each sections holds its components e.g. Vim's current mode.
123
124 ### Configuring lualine in init.vim
125
126 All the examples below are in lua. You can use the same examples
127 in `.vim` files by wrapping them in lua heredoc like this:
128
129 ```vim
130 lua << END
131 require('lualine').setup()
132 END
133 ```
134
135 For more information, check out `:help lua-heredoc`.
136
137 #### Default configuration
138
139 ```lua
140 require('lualine').setup {
141 options = {
142 icons_enabled = true,
143 theme = 'auto',
144 component_separators = { left = '', right = ''},
145 section_separators = { left = '', right = ''},
146 disabled_filetypes = {
147 statusline = {},
148 winbar = {},
149 },
150 ignore_focus = {},
151 always_divide_middle = true,
152 always_show_tabline = true,
153 globalstatus = false,
154 refresh = {
155 statusline = 1000,
156 tabline = 1000,
157 winbar = 1000,
158 refresh_time = 16, -- ~60fps
159 events = {
160 'WinEnter',
161 'BufEnter',
162 'BufWritePost',
163 'SessionLoadPost',
164 'FileChangedShellPost',
165 'VimResized',
166 'Filetype',
167 'CursorMoved',
168 'CursorMovedI',
169 'ModeChanged',
170 },
171 }
172 },
173 sections = {
174 lualine_a = {'mode'},
175 lualine_b = {'branch', 'diff', 'diagnostics'},
176 lualine_c = {'filename'},
177 lualine_x = {'encoding', 'fileformat', 'filetype'},
178 lualine_y = {'progress'},
179 lualine_z = {'location'}
180 },
181 inactive_sections = {
182 lualine_a = {},
183 lualine_b = {},
184 lualine_c = {'filename'},
185 lualine_x = {'location'},
186 lualine_y = {},
187 lualine_z = {}
188 },
189 tabline = {},
190 winbar = {},
191 inactive_winbar = {},
192 extensions = {}
193 }
194 ```
195
196 If you want to get your current lualine config, you can
197 do so with:
198
199 ```lua
200 require('lualine').get_config()
201
202 ```
203
204 ---
205
206 ### Starting lualine
207
208 ```lua
209 require('lualine').setup()
210 ```
211
212 ---
213
214 ### Setting a theme
215
216 ```lua
217 options = { theme = 'gruvbox' }
218 ```
219
220 All available themes are listed in [THEMES.md](./THEMES.md).
221
222 Please create a PR if you managed to port a popular theme before us, [here is how to do it](./CONTRIBUTING.md).
223
224 #### Customizing themes
225
226 ```lua
227 local custom_gruvbox = require'lualine.themes.gruvbox'
228
229 -- Change the background of lualine_c section for normal mode
230 custom_gruvbox.normal.c.bg = '#112233'
231
232 require('lualine').setup {
233 options = { theme = custom_gruvbox },
234 ...
235 }
236 ```
237
238 Theme structure is available [here](https://github.com/nvim-lualine/lualine.nvim/wiki/Writing-a-theme).
239
240 ---
241
242 ### Separators
243
244 lualine defines two kinds of separators:
245
246 - `section_separators` - separators between sections
247 - `component_separators` - separators between the different components in sections
248
249 **Note**: if viewing this README in a browser, chances are the characters below will not be visible.
250
251 ```lua
252 options = {
253 section_separators = { left = '', right = '' },
254 component_separators = { left = '', right = '' }
255 }
256 ```
257
258 Here, left refers to the left-most sections (a, b, c), and right refers
259 to the right-most sections (x, y, z).
260
261 #### Disabling separators
262
263 ```lua
264 options = { section_separators = '', component_separators = '' }
265 ```
266
267 ---
268
269 ### Changing components in lualine sections
270
271 ```lua
272 sections = {lualine_a = {'mode'}}
273 ```
274
275 #### Available components
276
277 - `branch` (git branch)
278 - `buffers` (shows currently available buffers)
279 - `diagnostics` (diagnostics count from your preferred source)
280 - `diff` (git diff status)
281 - `encoding` (file encoding)
282 - `fileformat` (file format)
283 - `filename`
284 - `filesize`
285 - `filetype`
286 - `hostname`
287 - `location` (location in file in line:column format)
288 - `mode` (vim mode)
289 - `progress` (%progress in file)
290 - `searchcount` (number of search matches when hlsearch is active)
291 - `selectioncount` (number of selected characters or lines)
292 - `tabs` (shows currently available tabs)
293 - `windows` (shows currently available windows)
294 - `lsp_status` (shows active LSPs in the current buffer and a progress spinner)
295
296 #### Custom components
297
298 ##### Lua functions as lualine component
299
300 ```lua
301 local function hello()
302 return [[hello world]]
303 end
304 sections = { lualine_a = { hello } }
305 ```
306
307 ##### Vim functions as lualine component
308
309 ```lua
310 sections = { lualine_a = {'FugitiveHead'} }
311 ```
312
313 ##### Vim's statusline items as lualine component
314
315 ```lua
316 sections = { lualine_c = {'%=', '%t%m', '%3p'} }
317 ```
318
319 ##### Vim variables as lualine component
320
321 Variables from `g:`, `v:`, `t:`, `w:`, `b:`, `o:`, `to:`, `wo:`, `bo:` scopes can be used.
322
323 See `:h lua-vim-variables` and `:h lua-vim-options` if you are not sure what to use.
324
325 ```lua
326 sections = { lualine_a = { 'g:coc_status', 'bo:filetype' } }
327 ```
328
329 ##### Lua expressions as lualine component
330
331 You can use any valid lua expression as a component including:
332
333 - oneliners
334 - global variables
335 - require statements
336
337 ```lua
338 sections = { lualine_c = { "os.date('%a')", 'data', "require'lsp-status'.status()" } }
339 ```
340
341 `data` is a global variable in this example.
342
343 ---
344
345 ### Component options
346
347 Component options can change the way a component behave.
348 There are two kinds of options:
349
350 - global options affecting all components
351 - local options affecting specific
352
353 Global options can be used as local options (can be applied to specific components)
354 but you cannot use local options as global.
355 Global option used locally overwrites the global, for example:
356
357 ```lua
358 require('lualine').setup {
359 options = { fmt = string.lower },
360 sections = { lualine_a = {
361 { 'mode', fmt = function(str) return str:sub(1,1) end } },
362 lualine_b = {'branch'} }
363 }
364 ```
365
366 `mode` will be formatted with the passed function so only first char will be
367 shown . On the other hand branch will be formatted with global formatter
368 `string.lower` so it will be showed in lower case.
369
370 #### Available options
371
372 #### Global options
373
374 These are `options` that are used in options table.
375 They set behavior of lualine.
376
377 Values set here are treated as default for other options
378 that work in component level.
379
380 For example even though `icons_enabled` is a general component option.
381 You can set `icons_enabled` to `false` and icons will be disabled on all
382 component. You can still overwrite defaults set in option table by specifying
383 the option value in component.
384
385 ```lua
386 options = {
387 theme = 'auto', -- lualine theme
388 component_separators = { left = '', right = '' },
389 section_separators = { left = '', right = '' },
390 disabled_filetypes = { -- Filetypes to disable lualine for.
391 statusline = {}, -- only ignores the ft for statusline.
392 winbar = {}, -- only ignores the ft for winbar.
393 },
394
395 ignore_focus = {}, -- If current filetype is in this list it'll
396 -- always be drawn as inactive statusline
397 -- and the last window will be drawn as active statusline.
398 -- for example if you don't want statusline of
399 -- your file tree / sidebar window to have active
400 -- statusline you can add their filetypes here.
401 --
402 -- Can also be set to a function that takes the
403 -- currently focused window as its only argument
404 -- and returns a boolean representing whether the
405 -- window's statusline should be drawn as inactive.
406
407 always_divide_middle = true, -- When set to true, left sections i.e. 'a','b' and 'c'
408 -- can't take over the entire statusline even
409 -- if neither of 'x', 'y' or 'z' are present.
410
411 always_show_tabline = true -- When set to true, if you have configured lualine for displaying tabline
412 -- then tabline will always show. If set to false, then tabline will be displayed
413 -- only when there are more than 1 tab. (see :h showtabline)
414
415 globalstatus = false, -- enable global statusline (have a single statusline
416 -- at bottom of neovim instead of one for every window).
417 -- This feature is only available in neovim 0.7 and higher.
418
419 refresh = { -- sets how often lualine should refresh it's contents (in ms)
420 statusline = 100, -- The refresh option sets minimum time that lualine tries
421 tabline = 100, -- to maintain between refresh. It's not guarantied if situation
422 winbar = 100 -- arises that lualine needs to refresh itself before this time
423 -- it'll do it.
424 refresh_time = 16, -- ~60fps the time after which refresh queue is processed. Mininum refreshtime for lualine
425 events = { -- The auto command events at which lualine refreshes
426 'WinEnter',
427 'BufEnter',
428 'BufWritePost',
429 'SessionLoadPost',
430 'FileChangedShellPost',
431 'VimResized',
432 'Filetype',
433 'CursorMoved',
434 'CursorMovedI',
435 'ModeChanged',
436 },
437 -- Also you can force lualine's refresh by calling refresh function
438 -- like require('lualine').refresh()
439 }
440 }
441 ```
442
443 #### General component options
444
445 These are options that control behavior at component level
446 and are available for all components.
447
448 ```lua
449 sections = {
450 lualine_a = {
451 {
452 'mode',
453 icons_enabled = true, -- Enables the display of icons alongside the component.
454 -- Defines the icon to be displayed in front of the component.
455 -- Can be string|table
456 -- As table it must contain the icon as first entry and can use
457 -- color option to custom color the icon. Example:
458 -- {'branch', icon = ''} / {'branch', icon = {'', color={fg='green'}}}
459
460 -- icon position can also be set to the right side from table. Example:
461 -- {'branch', icon = {'', align='right', color={fg='green'}}}
462 icon = nil,
463
464 separator = nil, -- Determines what separator to use for the component.
465 -- Note:
466 -- When a string is provided it's treated as component_separator.
467 -- When a table is provided it's treated as section_separator.
468 -- Passing an empty string disables the separator.
469 --
470 -- These options can be used to set colored separators
471 -- around a component.
472 --
473 -- The options need to be set as such:
474 -- separator = { left = '', right = ''}
475 --
476 -- Where left will be placed on left side of component,
477 -- and right will be placed on its right.
478 --
479
480 cond = nil, -- Condition function, the component is loaded when the function returns `true`.
481
482 draw_empty = false, -- Whether to draw component even if it's empty.
483 -- Might be useful if you want just the separator.
484
485 -- Defines a custom color for the component:
486 --
487 -- 'highlight_group_name' | { fg = '#rrggbb'|cterm_value(0-255)|'color_name(red)', bg= '#rrggbb', gui='style' } | function
488 -- Note:
489 -- '|' is synonymous with 'or', meaning a different acceptable format for that placeholder.
490 -- 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' })
491 -- color functions can be used to have different colors based on state as shown below.
492 --
493 -- Examples:
494 -- color = { fg = '#ffaa88', bg = 'grey', gui='italic,bold' },
495 -- color = { fg = 204 } -- When fg/bg are omitted, they default to the your theme's fg/bg.
496 -- color = 'WarningMsg' -- Highlight groups can also be used.
497 -- color = function(section)
498 -- return { fg = vim.bo.modified and '#aa3355' or '#33aa88' }
499 -- end,
500 color = nil, -- The default is your theme's color for that section and mode.
501
502 -- Specify what type a component is, if omitted, lualine will guess it for you.
503 --
504 -- Available types are:
505 -- [format: type_name(example)], mod(branch/filename),
506 -- stl(%f/%m), var(g:coc_status/bo:modifiable),
507 -- lua_expr(lua expressions), vim_fun(viml function name)
508 --
509 -- Note:
510 -- lua_expr is short for lua-expression and vim_fun is short for vim-function.
511 type = nil,
512
513 padding = 1, -- Adds padding to the left and right of components.
514 -- Padding can be specified to left or right independently, e.g.:
515 -- padding = { left = left_padding, right = right_padding }
516
517 fmt = nil, -- Format function, formats the component's output.
518 -- This function receives two arguments:
519 -- - string that is going to be displayed and
520 -- that can be changed, enhanced and etc.
521 -- - context object with information you might
522 -- need. E.g. tabnr if used with tabs.
523 on_click = nil, -- takes a function that is called when component is clicked with mouse.
524 -- the function receives several arguments
525 -- - number of clicks in case of multiple clicks
526 -- - mouse button used (l(left)/r(right)/m(middle)/...)
527 -- - modifiers pressed (s(shift)/c(ctrl)/a(alt)/m(meta)...)
528 }
529 }
530 }
531 ```
532
533 #### Component specific options
534
535 These are options that are available on specific components.
536 For example, you have option on `diagnostics` component to
537 specify what your diagnostic sources will be.
538
539 #### buffers component options
540
541 ```lua
542 sections = {
543 lualine_a = {
544 {
545 'buffers',
546 show_filename_only = true, -- Shows shortened relative path when set to false.
547 hide_filename_extension = false, -- Hide filename extension when set to true.
548 show_modified_status = true, -- Shows indicator when the buffer is modified.
549
550 mode = 0, -- 0: Shows buffer name
551 -- 1: Shows buffer index
552 -- 2: Shows buffer name + buffer index
553 -- 3: Shows buffer number
554 -- 4: Shows buffer name + buffer number
555
556 max_length = vim.o.columns * 2 / 3, -- Maximum width of buffers component,
557 -- it can also be a function that returns
558 -- the value of `max_length` dynamically.
559 filetype_names = {
560 TelescopePrompt = 'Telescope',
561 dashboard = 'Dashboard',
562 packer = 'Packer',
563 fzf = 'FZF',
564 alpha = 'Alpha'
565 }, -- Shows specific buffer name for that filetype ( { `filetype` = `buffer_name`, ... } )
566
567 -- Automatically updates active buffer color to match color of other components (will be overidden if buffers_color is set)
568 use_mode_colors = false,
569
570 buffers_color = {
571 -- Same values as the general color option can be used here.
572 active = 'lualine_{section}_normal', -- Color for active buffer.
573 inactive = 'lualine_{section}_inactive', -- Color for inactive buffer.
574 },
575
576 symbols = {
577 modified = ' ●', -- Text to show when the buffer is modified
578 alternate_file = '#', -- Text to show to identify the alternate file
579 directory = '', -- Text to show when the buffer is a directory
580 },
581 }
582 }
583 }
584 ```
585
586 #### datetime component options
587
588 ```lua
589 sections = {
590 lualine_a = {
591 {
592 'datetime',
593 -- options: default, us, uk, iso, or your own format string ("%H:%M", etc..)
594 style = 'default'
595 }
596 }
597 }
598 ```
599
600 #### diagnostics component options
601
602 ```lua
603 sections = {
604 lualine_a = {
605 {
606 'diagnostics',
607
608 -- Table of diagnostic sources, available sources are:
609 -- 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic', 'coc', 'ale', 'vim_lsp'.
610 -- or a function that returns a table as such:
611 -- { error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt }
612 sources = { 'nvim_diagnostic', 'coc' },
613
614 -- Displays diagnostics for the defined severity types
615 sections = { 'error', 'warn', 'info', 'hint' },
616
617 diagnostics_color = {
618 -- Same values as the general color option can be used here.
619 error = 'DiagnosticError', -- Changes diagnostics' error color.
620 warn = 'DiagnosticWarn', -- Changes diagnostics' warn color.
621 info = 'DiagnosticInfo', -- Changes diagnostics' info color.
622 hint = 'DiagnosticHint', -- Changes diagnostics' hint color.
623 },
624 symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'},
625 colored = true, -- Displays diagnostics status in color if set to true.
626 update_in_insert = false, -- Update diagnostics in insert mode.
627 always_visible = false, -- Show diagnostics even if there are none.
628 }
629 }
630 }
631 ```
632
633 #### diff component options
634
635 ```lua
636 sections = {
637 lualine_a = {
638 {
639 'diff',
640 colored = true, -- Displays a colored diff status if set to true
641 diff_color = {
642 -- Same color values as the general color option can be used here.
643 added = 'LuaLineDiffAdd', -- Changes the diff's added color
644 modified = 'LuaLineDiffChange', -- Changes the diff's modified color
645 removed = 'LuaLineDiffDelete', -- Changes the diff's removed color you
646 },
647 symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the symbols used by the diff.
648 source = nil, -- A function that works as a data source for diff.
649 -- It must return a table as such:
650 -- { added = add_count, modified = modified_count, removed = removed_count }
651 -- or nil on failure. count <= 0 won't be displayed.
652 }
653 }
654 }
655 ```
656
657 #### fileformat component options
658
659 ```lua
660 sections = {
661 lualine_a = {
662 {
663 'fileformat',
664 symbols = {
665 unix = '', -- e712
666 dos = '', -- e70f
667 mac = '', -- e711
668 }
669 }
670 }
671 }
672 ```
673
674 #### filename component options
675
676 ```lua
677 sections = {
678 lualine_a = {
679 {
680 'filename',
681 file_status = true, -- Displays file status (readonly status, modified status)
682 newfile_status = false, -- Display new file status (new file means no write after created)
683 path = 0, -- 0: Just the filename
684 -- 1: Relative path
685 -- 2: Absolute path
686 -- 3: Absolute path, with tilde as the home directory
687 -- 4: Filename and parent dir, with tilde as the home directory
688
689 shorting_target = 40, -- Shortens path to leave 40 spaces in the window
690 -- for other components. (terrible name, any suggestions?)
691 -- It can also be a function that returns
692 -- the value of `shorting_target` dynamically.
693 symbols = {
694 modified = '[+]', -- Text to show when the file is modified.
695 readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
696 unnamed = '[No Name]', -- Text to show for unnamed buffers.
697 newfile = '[New]', -- Text to show for newly created file before first write
698 }
699 }
700 }
701 }
702 ```
703
704 #### filetype component options
705
706 ```lua
707 sections = {
708 lualine_a = {
709 {
710 'filetype',
711 colored = true, -- Displays filetype icon in color if set to true
712 icon_only = false, -- Display only an icon for filetype
713 icon = { align = 'right' }, -- Display filetype icon on the right hand side
714 -- icon = {'X', align='right'}
715 -- Icon string ^ in table is ignored in filetype component
716 }
717 }
718 }
719 ```
720
721 #### encoding component options
722
723 ```lua
724 sections = {
725 lualine_a = {
726 {
727 'encoding',
728 -- Show '[BOM]' when the file has a byte-order mark
729 show_bomb = false,
730 }
731 }
732 }
733 ```
734
735 #### searchcount component options
736
737 ```lua
738 sections = {
739 lualine_a = {
740 {
741 'searchcount',
742 maxcount = 999,
743 timeout = 500,
744 }
745 }
746 }
747 ```
748
749 #### tabs component options
750
751 ```lua
752 sections = {
753 lualine_a = {
754 {
755 'tabs',
756 tab_max_length = 40, -- Maximum width of each tab. The content will be shorten dynamically (example: apple/orange -> a/orange)
757 max_length = vim.o.columns / 3, -- Maximum width of tabs component.
758 -- Note:
759 -- It can also be a function that returns
760 -- the value of `max_length` dynamically.
761 mode = 0, -- 0: Shows tab_nr
762 -- 1: Shows tab_name
763 -- 2: Shows tab_nr + tab_name
764
765 path = 0, -- 0: just shows the filename
766 -- 1: shows the relative path and shorten $HOME to ~
767 -- 2: shows the full path
768 -- 3: shows the full path and shorten $HOME to ~
769
770 -- Automatically updates active tab color to match color of other components (will be overidden if buffers_color is set)
771 use_mode_colors = false,
772
773 tabs_color = {
774 -- Same values as the general color option can be used here.
775 active = 'lualine_{section}_normal', -- Color for active tab.
776 inactive = 'lualine_{section}_inactive', -- Color for inactive tab.
777 },
778
779 show_modified_status = true, -- Shows a symbol next to the tab name if the file has been modified.
780 symbols = {
781 modified = '[+]', -- Text to show when the file is modified.
782 },
783
784 fmt = function(name, context)
785 -- Show + if buffer is modified in tab
786 local buflist = vim.fn.tabpagebuflist(context.tabnr)
787 local winnr = vim.fn.tabpagewinnr(context.tabnr)
788 local bufnr = buflist[winnr]
789 local mod = vim.fn.getbufvar(bufnr, '&mod')
790
791 return name .. (mod == 1 and ' +' or '')
792 end
793 }
794 }
795 }
796 ```
797
798 #### windows component options
799
800 ```lua
801 sections = {
802 lualine_a = {
803 {
804 'windows',
805 show_filename_only = true, -- Shows shortened relative path when set to false.
806 show_modified_status = true, -- Shows indicator when the window is modified.
807
808 mode = 0, -- 0: Shows window name
809 -- 1: Shows window index
810 -- 2: Shows window name + window index
811
812 max_length = vim.o.columns * 2 / 3, -- Maximum width of windows component,
813 -- it can also be a function that returns
814 -- the value of `max_length` dynamically.
815 filetype_names = {
816 TelescopePrompt = 'Telescope',
817 dashboard = 'Dashboard',
818 packer = 'Packer',
819 fzf = 'FZF',
820 alpha = 'Alpha'
821 }, -- Shows specific window name for that filetype ( { `filetype` = `window_name`, ... } )
822
823 disabled_buftypes = { 'quickfix', 'prompt' }, -- Hide a window if its buffer's type is disabled
824
825 -- Automatically updates active window color to match color of other components (will be overidden if buffers_color is set)
826 use_mode_colors = false,
827
828 windows_color = {
829 -- Same values as the general color option can be used here.
830 active = 'lualine_{section}_normal', -- Color for active window.
831 inactive = 'lualine_{section}_inactive', -- Color for inactive window.
832 },
833 }
834 }
835 }
836 ```
837
838 #### lsp status component options
839
840 ```lua
841 sections = {
842 lualine_a = {
843 {
844 'lsp_status',
845 icon = '', -- f013
846 symbols = {
847 -- Standard unicode symbols to cycle through for LSP progress:
848 spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' },
849 -- Standard unicode symbol for when LSP is done:
850 done = '✓',
851 -- Delimiter inserted between LSP names:
852 separator = ' ',
853 },
854 -- List of LSP names to ignore (e.g., `null-ls`):
855 ignore_lsp = {},
856 -- Display the LSP name
857 show_name = true,
858 }
859 }
860 }
861 ```
862
863 ---
864
865 ### Tabline
866
867 You can use lualine to display components in tabline.
868 The configuration for tabline sections is exactly the same as that of the statusline.
869
870 ```lua
871 tabline = {
872 lualine_a = {},
873 lualine_b = {'branch'},
874 lualine_c = {'filename'},
875 lualine_x = {},
876 lualine_y = {},
877 lualine_z = {}
878 }
879 ```
880
881 This will show the branch and filename components on top of neovim inside tabline.
882
883 lualine also provides 2 components, buffers and tabs, that you can use to get a more traditional tabline/bufferline.
884
885 ```lua
886 tabline = {
887 lualine_a = {'buffers'},
888 lualine_b = {'branch'},
889 lualine_c = {'filename'},
890 lualine_x = {},
891 lualine_y = {},
892 lualine_z = {'tabs'}
893 }
894 ```
895
896 ### Winbar
897
898 From neovim-0.8 you can customize your winbar with lualine.
899 Winbar configuration is similar to statusline.
900
901 ```lua
902 winbar = {
903 lualine_a = {},
904 lualine_b = {},
905 lualine_c = {'filename'},
906 lualine_x = {},
907 lualine_y = {},
908 lualine_z = {}
909 }
910
911 inactive_winbar = {
912 lualine_a = {},
913 lualine_b = {},
914 lualine_c = {'filename'},
915 lualine_x = {},
916 lualine_y = {},
917 lualine_z = {}
918 }
919 ```
920
921 Just like statusline you can separately specify winbar for active and inactive
922 windows. Any lualine component can be placed in winbar. All kinds of custom
923 components supported in statusline are also supported for winbar too. In general
924 You can treat winbar as another lualine statusline that just appears on top
925 of windows instead of at bottom.
926
927 #### Buffers
928
929 Shows currently open buffers. Like bufferline . See
930 [buffers options](#buffers-component-options)
931 for all builtin behaviors of buffers component.
932 You can use `:LualineBuffersJump` to jump to buffer based on index
933 of buffer in buffers component.
934 Jumping to non-existent buffer indices generates an error. To avoid these errors
935 `LualineBuffersJump` provides `<bang>` support, meaning that you can call
936 `:LualineBufferJump!` to ignore these errors.
937
938 ```vim
939 :LualineBuffersJump 2 " Jumps to 2nd buffer in buffers component.
940 :LualineBuffersJump $ " Jumps to last buffer in buffers component.
941 :LualineBuffersJump! 3 " Attempts to jump to 3rd buffer, if it exists.
942 ```
943
944 #### Tabs
945
946 Shows currently open tab. Like usual tabline. See
947 [tabs options](#tabs-component-options)
948 for all builtin behaviors of tabs component.
949 You can also use `:LualineRenameTab` to set a name for a tabpage.
950 For example:
951
952 ```vim
953 :LualineRenameTab Project_K
954 ```
955
956 It's useful when you're using rendering mode 2/3 in tabs.
957 To unname a tabpage run `:LualineRenameTab` without argument.
958
959 #### Tabline as statusline
960
961 You can also completely move your statusline to a tabline by configuring
962 `lualine.tabline` and disabling `lualine.sections` and `lualine.inactive_sections`:
963
964 ```lua
965 tabline = {
966 ......
967 },
968 sections = {},
969 inactive_sections = {},
970 ```
971
972 If you want a more sophisticated tabline you can use other
973 tabline plugins with lualine too, for example:
974
975 - [nvim-bufferline](https://github.com/akinsho/nvim-bufferline.lua)
976 - [tabline.nvim](https://github.com/kdheepak/tabline.nvim)
977
978 tabline.nvim even uses lualine's theme by default 🙌
979 You can find a bigger list [here](https://github.com/rockerBOO/awesome-neovim#tabline).
980
981 ---
982
983 ### Extensions
984
985 lualine extensions change statusline appearance for a window/buffer with
986 specified filetypes.
987
988 By default no extensions are loaded to improve performance.
989 You can load extensions with:
990
991 ```lua
992 extensions = {'quickfix'}
993 ```
994
995 #### Available extensions
996
997 - aerial
998 - assistant
999 - avante
1000 - chadtree
1001 - ctrlspace
1002 - fern
1003 - fugitive
1004 - fzf
1005 - lazy
1006 - man
1007 - mason
1008 - mundo
1009 - neo-tree
1010 - nerdtree
1011 - nvim-dap-ui
1012 - nvim-tree
1013 - oil
1014 - overseer
1015 - quickfix
1016 - symbols-outline
1017 - toggleterm
1018 - trouble
1019
1020 #### Custom extensions
1021
1022 You can define your own extensions. If you believe an extension may be useful to others, then please submit a PR.
1023
1024 ```lua
1025 local my_extension = { sections = { lualine_a = {'mode'} }, filetypes = {'lua'} }
1026 require('lualine').setup { extensions = { my_extension } }
1027 ```
1028
1029 ---
1030
1031 ### Refreshing lualine
1032
1033 By default lualine refreshes itself based on timer and some events. You can set
1034 the interval of the timer with refresh option. However you can also force
1035 lualine to refresh at any time by calling `lualine.refresh` function.
1036
1037 ```lua
1038 require('lualine').refresh({
1039 scope = 'tabpage', -- scope of refresh all/tabpage/window
1040 place = { 'statusline', 'winbar', 'tabline' }, -- lualine segment ro refresh.
1041 })
1042 ```
1043
1044 The arguments shown here are default values. So not passing any of them will be
1045 treated as if a default value was passed.
1046
1047 So you can simply do
1048
1049 ```lua
1050 require('lualine').refresh()
1051 ```
1052
1053 Also, note by default when you call refresh a refresh event is queued in lualine.
1054 It desn't refresh event immidiately. It'll refresh on next refresh check pass.
1055 By default this time is set to 16ms to match 60fps. This duration can be configured
1056 with `options.refresh.refresh_time` option. If you want to bypass the refresh queue
1057 and want lualine to process the refresh immmidiately call refresh with `force=true`
1058 parameter set like this.
1059 ```lua
1060 require('lualine').refresh({
1061 force = true, -- do an immidiate refresh
1062 scope = 'tabpage', -- scope of refresh all/tabpage/window
1063 place = { 'statusline', 'winbar', 'tabline' }, -- lualine segment ro refresh.
1064 })
1065 ```
1066 Practically, speaking this is almost never needed. Also you should avoid calling
1067 `lualine.refresh` with `force` inside components. Since components are
1068 evaluated during refresh, calling refresh while refreshing can have undesirable
1069 effects.
1070
1071
1072 ### Disabling lualine
1073
1074 You can disable lualine for specific filetypes:
1075
1076 ```lua
1077 options = { disabled_filetypes = {'lua'} }
1078 ```
1079
1080 You can also disable lualine completely.
1081 Note that you need to call this after the setup
1082
1083 ```lua
1084 require('lualine').hide({
1085 place = {'statusline', 'tabline', 'winbar'}, -- The segment this change applies to.
1086 unhide = false, -- whether to re-enable lualine again/
1087 })
1088 ```
1089
1090 The arguments show for hide above are default values.
1091 Which means even if the hide function is called without
1092 arguments it'll work as if these were passed.
1093
1094 So in short to disable lualine completely you can do
1095
1096 ```lua
1097 require('lualine').hide()
1098 ```
1099
1100 To enable it again you can do
1101
1102 ```lua
1103 require('lualine').hide({unhide=true})
1104 ```
1105
1106 <!-- panvimdoc-ignore-start -->
1107
1108 ### Contributors
1109
1110 Thanks to these wonderful people, we enjoy this awesome plugin.
1111
1112 <a href="https://github.com/nvim-lualine/lualine.nvim/graphs/contributors">
1113 <img src="https://contrib.rocks/image?repo=nvim-lualine/lualine.nvim" />
1114 </a>
1115
1116 <!-- panvimdoc-ignore-end -->
1117
1118 ### Wiki
1119
1120 Check out the [wiki](https://github.com/nvim-lualine/lualine.nvim/wiki) for more info.
1121
1122 You can find some useful [configuration snippets](https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets) here. You can also share your awesome snippets with others.
1123
1124 If you want to extend lualine with plugins or want to know
1125 which ones already do, [wiki/plugins](https://github.com/nvim-lualine/lualine.nvim/wiki/Plugins) is for you.