GithubHelp home page GithubHelp logo

nvim-lualine / lualine.nvim Goto Github PK

View Code? Open in Web Editor NEW
5.4K 19.0 447.0 1.35 MB

A blazing fast and easy to configure neovim statusline plugin written in pure lua.

License: MIT License

Lua 98.38% Makefile 0.25% Shell 1.37%
neovim statusline neovim-statusline nvim lua neovim-plugin neovim-lua lualine

lualine.nvim's Introduction

lualine.nvim

code size license

A blazing fast and easy to configure Neovim statusline written in Lua.

lualine.nvim requires Neovim >= 0.7.

For previous versions of neovim please use compatability tags for example compat-nvim-0.5

Contributing

Feel free to create an issue/PR if you want to see anything else implemented. If you have some question or need help with configuration, start a discussion.

Please read CONTRIBUTING.md before opening a PR. You can also help with documentation in the wiki.

Screenshots

Here is a preview of what lualine can look like.

Screenshots of all available themes are listed in THEMES.md

For those who want to break the norms, you can create custom looks for lualine.

Example :

Performance compared to other plugins

Unlike other statusline plugins, lualine loads only the components you specify, and nothing else.

Startup time performance measured with an amazing plugin dstein64/vim-startuptime

Times are measured with a clean init.vim with only vim-startuptime, vim-plug and given statusline plugin installed. In control just vim-startuptime andvim-plug is installed. And measured time is complete startuptime of vim not time spent on specific plugin. These numbers are the average of 20 runs.

control lualine lightline airline
17.2 ms 24.8 ms 25.5 ms 79.9 ms

Last Updated On: 18-04-2022

Installation

Plug 'nvim-lualine/lualine.nvim'
" If you want to have icons in your statusline choose one of these
Plug 'nvim-tree/nvim-web-devicons'
use {
  'nvim-lualine/lualine.nvim',
  requires = { 'nvim-tree/nvim-web-devicons', opt = true }
}
{
    'nvim-lualine/lualine.nvim',
    dependencies = { 'nvim-tree/nvim-web-devicons' }
}

You'll also need to have a patched font if you want icons.

Usage and customization

Lualine has sections as shown below.

+-------------------------------------------------+
| A | B | C                             X | Y | Z |
+-------------------------------------------------+

Each sections holds its components e.g. Vim's current mode.

Configuring lualine in init.vim

All the examples below are in lua. You can use the same examples in .vim files by wrapping them in lua heredoc like this:

lua << END
require('lualine').setup()
END

For more information, check out :help lua-heredoc.

Default configuration

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,
    globalstatus = false,
    refresh = {
      statusline = 1000,
      tabline = 1000,
      winbar = 1000,
    }
  },
  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 = {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {'filename'},
    lualine_x = {'location'},
    lualine_y = {},
    lualine_z = {}
  },
  tabline = {},
  winbar = {},
  inactive_winbar = {},
  extensions = {}
}

If you want to get your current lualine config, you can do so with:

require('lualine').get_config()

Starting lualine

require('lualine').setup()

Setting a theme

options = { theme = 'gruvbox' }

All available themes are listed in THEMES.md.

Please create a PR if you managed to port a popular theme before us, here is how to do it.

Customizing themes

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 },
  ...
}

Theme structure is available here.


Separators

lualine defines two kinds of separators:

  • section_separators - separators between sections
  • component_separators - separators between the different components in sections

Note: if viewing this README in a browser, chances are the characters below will not be visible.

options = {
  section_separators = { left = '', right = '' },
  component_separators = { left = '', right = '' }
}

Here, left refers to the left-most sections (a, b, c), and right refers to the right-most sections (x, y, z).

Disabling separators

options = { section_separators = '', component_separators = '' }

Changing components in lualine sections

sections = {lualine_a = {'mode'}}

Available components

  • branch (git branch)
  • buffers (shows currently available buffers)
  • diagnostics (diagnostics count from your preferred source)
  • diff (git diff status)
  • encoding (file encoding)
  • fileformat (file format)
  • filename
  • filesize
  • filetype
  • hostname
  • location (location in file in line:column format)
  • mode (vim mode)
  • progress (%progress in file)
  • searchcount (number of search matches when hlsearch is active)
  • selectioncount (number of selected characters or lines)
  • tabs (shows currently available tabs)
  • windows (shows currently available windows)

Custom components

Lua functions as lualine component
local function hello()
  return [[hello world]]
end
sections = { lualine_a = { hello } }
Vim functions as lualine component
sections = { lualine_a = {'FugitiveHead'} }
Vim's statusline items as lualine component
sections = { lualine_c = {'%=', '%t%m', '%3p'} }
Vim variables as lualine component

Variables from g:, v:, t:, w:, b:, o:, to:, wo:, bo: scopes can be used.

See :h lua-vim-variables and :h lua-vim-options if you are not sure what to use.

sections = { lualine_a = { 'g:coc_status', 'bo:filetype' } }
Lua expressions as lualine component

You can use any valid lua expression as a component including:

  • oneliners
  • global variables
  • require statements
sections = { lualine_c = { "os.date('%a')", 'data', "require'lsp-status'.status()" } }

data is a global variable in this example.


Component options

Component options can change the way a component behave. There are two kinds of options:

  • global options affecting all components
  • local options affecting specific

Global options can be used as local options (can be applied to specific components) but you cannot use local options as global. Global option used locally overwrites the global, for example:

    require('lualine').setup {
      options = { fmt = string.lower },
      sections = { lualine_a = {
        { 'mode', fmt = function(str) return str:sub(1,1) end } },
                  lualine_b = {'branch'} }
    }

mode will be formatted with the passed function so only first char will be shown . On the other hand branch will be formatted with global formatter string.lower so it will be showed in lower case.

Available options

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.

options = {
  theme = 'auto', -- lualine theme
  component_separators = { left = '', right = '' },
  section_separators = { left = '', right = '' },
  disabled_filetypes = {     -- Filetypes to disable lualine for.
      statusline = {},       -- only ignores the ft for statusline.
      winbar = {},           -- only ignores the ft for winbar.
  },

  ignore_focus = {},         -- If current filetype is in this list it'll
                             -- always be drawn as inactive statusline
                             -- and the last window will be drawn as active statusline.
                             -- for example if you don't want statusline of
                             -- your file tree / sidebar window to have active
                             -- statusline you can add their filetypes here.

  always_divide_middle = true, -- When set to true, left sections i.e. 'a','b' and 'c'
                               -- can't take over the entire statusline even
                               -- if neither of 'x', 'y' or 'z' are present.

  globalstatus = false,        -- enable global statusline (have a single statusline
                               -- at bottom of neovim instead of one for  every window).
                               -- This feature is only available in neovim 0.7 and higher.

  refresh = {                  -- sets how often lualine should refresh it's contents (in ms)
    statusline = 1000,         -- The refresh option sets minimum time that lualine tries
    tabline = 1000,            -- to maintain between refresh. It's not guarantied if situation
    winbar = 1000              -- arises that lualine needs to refresh itself before this time
                               -- it'll do it.

                               -- Also you can force lualine's refresh by calling refresh function
                               -- like require('lualine').refresh()
  }
}

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, -- 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)...)
    }
  }
}

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

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
      },
    }
  }
}

datetime component options

sections = {
  lualine_a = {
    {
      'datetime',
      -- options: default, us, uk, iso, or your own format string ("%H:%M", etc..)
      style = 'default'
    }
  }
}

diagnostics component options

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.
    }
  }
}

diff component options

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.
    }
  }
}

fileformat component options

sections = {
  lualine_a = {
    {
      'fileformat',
      symbols = {
        unix = '', -- e712
        dos = '',  -- e70f
        mac = '',  -- e711
      }
    }
  }
}

filename component options

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?)
      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
      }
    }
  }
}

filetype component options

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
    }
  }
}

searchcount component options

sections = {
  lualine_a = {
    {
      'searchcount',
      maxcount = 999,
      timeout = 500,
    }
  }
}

tabs component options

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
    }
  }
}

windows component options

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.
      },
    }
  }
}

Tabline

You can use lualine to display components in tabline. The configuration for tabline sections is exactly the same as that of the statusline.

tabline = {
  lualine_a = {},
  lualine_b = {'branch'},
  lualine_c = {'filename'},
  lualine_x = {},
  lualine_y = {},
  lualine_z = {}
}

This will show the branch and filename components on top of neovim inside tabline.

lualine also provides 2 components, buffers and tabs, that you can use to get a more traditional tabline/bufferline.

tabline = {
  lualine_a = {'buffers'},
  lualine_b = {'branch'},
  lualine_c = {'filename'},
  lualine_x = {},
  lualine_y = {},
  lualine_z = {'tabs'}
}

Winbar

From neovim-0.8 you can customize your winbar with lualine. Winbar configuration is similar to statusline.

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 = {}
}

Just like statusline you can separately specify winbar for active and inactive windows. Any lualine component can be placed in winbar. All kinds of custom components supported in statusline are also supported for winbar too. In general You can treat winbar as another lualine statusline that just appears on top of windows instead of at bottom.

Buffers

Shows currently open buffers. Like bufferline . See buffers options for all builtin behaviors of buffers component. You can use :LualineBuffersJump to jump to buffer based on index of buffer in buffers component. Jumping to non-existent buffer indices generates an error. To avoid these errors LualineBuffersJump provides <bang> support, meaning that you can call :LualineBufferJump! to ignore these errors.

  :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.

Tabs

Shows currently open tab. Like usual tabline. See tabs options for all builtin behaviors of tabs component. You can also use :LualineRenameTab to set a name for a tabpage. For example:

:LualineRenameTab Project_K

It's useful when you're using rendering mode 2/3 in tabs. To unname a tabpage run :LualineRenameTab without argument.

Tabline as statusline

You can also completely move your statusline to a tabline by configuring lualine.tabline and disabling lualine.sections and lualine.inactive_sections:

tabline = {
......
  },
sections = {},
inactive_sections = {},

If you want a more sophisticated tabline you can use other tabline plugins with lualine too, for example:

tabline.nvim even uses lualine's theme by default 🙌 You can find a bigger list here.


Extensions

lualine extensions change statusline appearance for a window/buffer with specified filetypes.

By default no extensions are loaded to improve performance. You can load extensions with:

extensions = {'quickfix'}

Available extensions

  • aerial
  • chadtree
  • ctrlspace
  • fern
  • fugitive
  • fzf
  • lazy
  • man
  • mason
  • mundo
  • neo-tree
  • nerdtree
  • nvim-dap-ui
  • nvim-tree
  • oil
  • overseer
  • quickfix
  • symbols-outline
  • toggleterm
  • trouble

Custom extensions

You can define your own extensions. If you believe an extension may be useful to others, then please submit a PR.

local my_extension = { sections = { lualine_a = {'mode'} }, filetypes = {'lua'} }
require('lualine').setup { extensions = { my_extension } }

Refreshing lualine

By default lualine refreshes itself based on timer and some events. You can set the interval of the timer with refresh option. However you can also force lualine to refresh at any time by calling lualine.refresh function.

require('lualine').refresh({
  scope = 'tabpage',  -- scope of refresh all/tabpage/window
  place = { 'statusline', 'winbar', 'tabline' },  -- lualine segment ro refresh.
})

The arguments shown here are default values. So not passing any of them will be treated as if a default value was passed.

So you can simply do

require('lualine').refresh()

Avoid calling lualine.refresh inside components. Since components are evaluated during refresh, calling refresh while refreshing can have undesirable effects.

Disabling lualine

You can disable lualine for specific filetypes:

options = { disabled_filetypes = {'lua'} }

You can also disable lualine completely. Note that you need to call this after the setup

  require('lualine').hide({
    place = {'statusline', 'tabline', 'winbar'}, -- The segment this change applies to.
    unhide = false,  -- whether to re-enable lualine again/
  })

The arguments show for hide above are default values. Which means even if the hide function is called without arguments it'll work as if these were passed.

So in short to disable lualine completely you can do

require('lualine').hide()

To enable it again you can do

require('lualine').hide({unhide=true})

Contributors

Thanks to these wonderful people, we enjoy this awesome plugin.

Wiki

Check out the wiki for more info.

You can find some useful configuration snippets here. You can also share your awesome snippets with others.

If you want to extend lualine with plugins or want to know which ones already do, wiki/plugins is for you.

lualine.nvim's People

Contributors

andreaugustodev avatar antoineco avatar camilledejoye avatar chris1320 avatar daephx avatar dcordb avatar dmun avatar dmytruek avatar fitrh avatar github-actions[bot] avatar grtcdr avatar hiberabyss avatar hoob3rt avatar jarviliam avatar jonathangin52 avatar kdheepak avatar kylo252 avatar matthewsia98 avatar mtoohey31 avatar nguyenvukhang avatar rockyzhang24 avatar saecki avatar shadmansaleh avatar shatur avatar timbedard avatar trevarj avatar willothy avatar yanskun avatar zappolowski avatar zeertzjq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lualine.nvim's Issues

expose configuration through vimscript

User should be able to configure lualine with vimscript through global vim variables eg

let g:lualine_theme = 'nord'

similarly this should be supported in lua

vim.g.lualine_theme = 'nord'

`<CTRL_C>` breaks lualine

This is not happening every time I hit CTRL_C but sometimes.

CTRL-C breaks lualine

The error is

E5108: Error executing lua Keyboard interrupt

diagnostic api

Create diagnostic api to handle & view diagnostics in lualine from multiple sources. For example while using Ale for linting with eslint and tsserver with lsp, diagnostics from both of these should be displayed in one component in lualine.

create doc file

Everything connected with lualine's customization should be available by :h lualine in neovim

[suggestion] use icons for fileformat

Instead of the boring unix, dos and mac for fileformat, one may use devicons (since they are also used for file types). More precisely, from https://www.nerdfonts.com/cheat-sheet, check out nf-dev-linux, nf-dev-windows and nf-dev-apple. Just eye-candy, but, hey, why not? (I do not think both icon and text should be provided. Icons if the possibility is there, text for fallback.)

Diff Colors do not reset

I have this as my lualine sections

      lualine.sections = {
        lualine_a = { 'mode' },
        lualine_b = { 'branch' },
        lualine_c = { 'filename', 'diff', 'g:coc_status' },
        lualine_x = { 'encoding', 'fileformat', 'filetype' },
        lualine_y = { 'progress' },
        lualine_z = { 'location' },
      }

This is how it renders
image

coc_status gets color of the diff.

Usage questions

Hello. Have couple of questions about lualine

  1. Can i put file_name to first a sections instead of mode section? When i try to do it it brokes sections separation.
    image

  2. How can i enable full path to file?

  3. Can lualine display progress section as currcnt_line/all_lines_number current_position_in_line (e.g. 22/290 5 for cursor position in 22 line and 5 column)

Breaks neovim's :tcd command (tab-local cwds)

Minimal init.lua:

lualine = require('lualine')
vim.cmd [[packadd packer.nvim]]
local plugins = require('packer').startup(function()
    use {'wbthomason/packer.nvim', opt = true}
    use {
        'hoob3rt/lualine.nvim',
        requires = 'kyazdani42/nvim-web-devicons',
    }
end)
lualine.status()

Steps to reproduce:

  1. nvim -u minimal-init.lua (from home directory)
  2. :pwd
  3. :tabnew
  4. :tcd ~/.config/nvim
  5. :pwd
  6. gt
  7. :pwd

Expected result:
Prints "/home/user" first time :pwd is called, "/home/user/.config/nvim" the second time, and "/home/user" the third time.

Actual result:
Prints "/home/user" first time, "/home/user/.config/nvim" second and third times.

The :tcd neovim command changes the cwd for only the current tab. But with this plugin installed, it changes it for all tabs.

Scrolling using vim-smoothie lags when lualine.nvim is enabled

  • nvim --version:
NVIM v0.5.0-dev+972-g84faeb07d
Build type: RelWithDebInfo
LuaJIT 2.0.5
  • latest versions of both plugins
  • terminal: kitty 0.19.3 (also occurs in xterm)

Scrolling using vim-smoothie while lualine.nvim is enabled produces lag, especially towards the end of the scrolling motion. This does not occur while using vim-airline (though lualine.nvim is the first statusline plugin I've ever used, but I had to test with another one).

Update screenshots in README.md

Since component separators were added we should update the screenshots in README.md as that's the landing page . THEMES.md can be updated too though that will be good amount of work . @hoob3rt didn't you say you had a script for screenshots?

May be update the screenshot when diagnostics is added :) . What do you think?

additional setting for components

as mentioned in #16 (comment) there should be additional settings for lualine's components. Something like

  • icon
  • padding
  • uppercase/lowercase

Let me know if you wish to have anything else supported.

OS icon show linux even OSX

the OS icon doesn't work, I think file format isn't the best option to get the OS. I don't know the best, I only know using has vim function. I've tried and it looks good.
I'd like to know what do you think @hoob3rt
PS. Mac/OSX needs to be first because it also return 1 to has('unix')
PS. I have a change here I didn't create the PR because first I'd like to know about you
Screenshot 2021-02-26 at 23 32 08

Development paused/stopped?

It is the beginnings of the project, but somehow there is no movement for 10 days in terms of any updates. The PRs are more than the issue tickets. Is everything OK? I am not pressuring, I just want to make sure this did not become abandoned, as I really like this status line.

Discuss: Remove cterm colors from themes

The genarated cterm values are pretty good . Most of the themes donn't have cterm values in them. Those cterm values create unnecessary complexicity in themes . Also since rest of the codebase relies on genarated cterm colors (like section separators) They can look weird if themes provide cterm values thata re different . So I think we should remove cterm values from themes and relay solely on genarted cterm values .

Change theme structure

I think mirroring theme on left(A,B,C) and right(X,Y,Z) is limiting.
I kind of like the left and right structure in lightline.
can we have something like that in lualine ?

I personally can't see how lualine's theme structure is limiting compared to lightline. Could you elaborate on what exactly are you missing?

Originally posted by @shadmansaleh in #23 (comment)

Porting onedark colorscheme

Wanted to port over the onedark color scheme used in airline. Attached is PR with change with reference to onedark's airline code (note I could not find the colors for 'command' mode). Let me know if there are any questions or issues!

PR: #8

Add support for all vim modes

Currently not all modes are supported which produces lualine crashes.

							*mode()*
mode([expr])	Return a string that indicates the current mode.
		If [expr] is supplied and it evaluates to a non-zero Number or
		a non-empty String (|non-zero-arg|), then the full mode is
		returned, otherwise only the first letter is returned.

		   n	    Normal
		   no	    Operator-pending
		   nov	    Operator-pending (forced charwise |o_v|)
		   noV	    Operator-pending (forced linewise |o_V|)
		   noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
				CTRL-V is one character
		   niI	    Normal using |i_CTRL-O| in |Insert-mode|
		   niR	    Normal using |i_CTRL-O| in |Replace-mode|
		   niV	    Normal using |i_CTRL-O| in |Virtual-Replace-mode|
		   v	    Visual by character
		   V	    Visual by line
		   CTRL-V   Visual blockwise
		   s	    Select by character
		   S	    Select by line
		   CTRL-S   Select blockwise
		   i	    Insert
		   ic	    Insert mode completion |compl-generic|
		   ix	    Insert mode |i_CTRL-X| completion
		   R	    Replace |R|
		   Rc	    Replace mode completion |compl-generic|
		   Rv	    Virtual Replace |gR|
		   Rx	    Replace mode |i_CTRL-X| completion
		   c	    Command-line editing
		   cv	    Vim Ex mode |gQ|
		   ce	    Normal Ex mode |Q|
		   r	    Hit-enter prompt
		   rm	    The -- more -- prompt
		   r?	    |:confirm| query of some sort
		   !	    Shell or external command is executing
		   t	    Terminal mode: keys go to the job
		This is useful in the 'statusline' option or when used
		with |remote_expr()| In most other places it always returns
		"c" or "n".
		Note that in the future more modes and more specific modes may
		be added. It's better not to compare the whole string but only
		the leading character(s).
		Also see |visualmode()|.

What's our approach on external plugin intigration?

I personaly agree with

The lightline.vim plugin does not provide any plugin integration by default. This plugin considers orthogonality to be one of the important ideas, which means that the plugin does not rely on implementation of other plugins. Once a plugin starts to integrate with some famous plugins, it should be kept updated to follow the changes of the plugins, and should accept integration requests with new plugins and it will suffer from performance regression due to plugin availability checks.

from lightline.
Currently our only external dependecy is signify.
That's why I think it's a good time to disscuss it . Should we intrigrate directly with external plugins or should we give users flexible tools to use any plugin with lightline themselves?

Git branch persists even after buffer change

Suppose I open a buffer and the file is at a git folder. The branch is displayed, which is good.

Now, I switch to another buffer with a file at another folder that is not (and neither its parents are) git-controlled. The git branch from the previous buffer will persist on the status line for the new buffer. Even if I close the previous buffer, the git branch persists.

Not sure what the issue is; maybe something about async?

In inactive buffer lualine show filetype from active buffer

I have this config:

local lualine = require('lualine')
lualine.sections = {
  lualine_a = { 'mode' },
  lualine_b = { 'filename' },
  lualine_x = { 'filetype' }
}

lualine.inactive_sections = {
  lualine_a = {  },
  lualine_b = { 'filename' },
  lualine_x = { 'filetype'  }
}
lualine.status()

I want lualine to show in the inactive buffer filetype and not progress.
With the above config shows filetype from active buffer.
If active buffer it's lua filetype and inactive buffer it's vim,
lualine in inactive buffer(which is vim filetype) shows lua filetype from active buffer.
vim-lightline shows this correctly.
Thank's for this beautiful plugin.

Bug: Signify added displayed in black

introduced in 3fecc95

The 'DiffAdd' group is for background highlighting it doesn't have a proper foreground property.
doing hi DiffAdd shpw only ctermbg and guibg properties . The default 'Diffchanged' & 'Diffdelete' are also background highlighter.

Funfact my colorscheme overrites them and makes the bg gray with foreground highlights . Colorchemes can make those colors look realy weird that's why I didn't want to extract colors from highlights :/

fall back to powerline font icons?

Right now, if lualine does not detect devicons it offers only text. As a fallback, one could check whether powerline font "icons" are available (cascadia code, IBM plex, ...). Then, for example, a git branch icon can be \ue0a0. Not everyone want to have patched fonts installed.

Doesn't work and no errors

I use NVIM v0.5.0-dev+916-gee5ece084
Installed lualine with Plug.
I have the following lines in my init.vim

lua << EOF
local lualine = require('lualine')
lualine.status()
EOF

I don't get any errors on startup but I don't see the bar either.
If I move lualine directory away from ~/.vim/plugged/ then I get an error that lualine is not found.

Disabling section/component separator does not work.

Current config

  use {
    'hoob3rt/lualine.nvim',
    requires = {'kyazdani42/nvim-web-devicons', opt = true},
    event = 'VimEnter *',
    config = function()
      require('lualine').setup{
        options = {
          theme = require('helpers').getLualineTheme(),
          icons_enabled = true,
          -- section_separators = nil, component_separators = nil
          component_separators = {'', ''},
          section_separators = {'', ''}
        },
        sections = {
          lualine_a = { 'mode' },
          lualine_b = { 'branch' },
          lualine_c = { 'filename', 'diff', 'g:coc_status' },
          lualine_x = { 'encoding', 'fileformat', 'filetype' },
          lualine_y = { 'progress' },
          lualine_z = { 'location' },
        },
        inactive_sections = {
          lualine_a = {  },
          lualine_b = { 'branch' },
          lualine_c = { 'filename' },
          lualine_x = {  },
          lualine_y = {  },
          lualine_z = { 'location' }
        },
        extensions = { 'fzf' }
      }
    end
  }

To disable separators, I tried using section_separators = nil, component_separators = nil which doesn't work. So I am currently setting empty values for them which works.

lualine_diagnostics section?

snippet from my lualine config file:

local M = {}

local function diagnostics()
...
end

function M.config()
    lualine.sections['lualine_diagnostics'] = { diagnostics }
    lualine.status()
end

return M

but nothing changes in my status line. If I set a different sections to my diagnostics function, it works as expected. But nothing shows when I set the lualine_diagnostics section.

Tabline

What do you think about using tabline?

Tabline and statusline use same formats right now you can do

vim.o.showtabline = 2
vim.o.tabline = vim.o.satusline
vim.o.statusline = ' '

And send statusline to top on vim . We could divide tabline into sections like statusline and allow users to put components to top of vim too. Say I could show stuff like mode and branch on top of vim insted of bottom ? We could probably also add a option to show traditional tabline too .

Oh I think the entire tabline should be optional . So users can use a different tabline plugin if they prefare it and not have two plugins fight over tabline😄

What do you think of the idea?

signify causes bad section highlights

setting signify compoent as the first component in section causes the padding to be in previous section's color. For some reason it only happens on on the left padding, not on the right.

@shadmansaleh maybe you have an idea on why this happens

This also affects the diagnostics component which is not yet merged.

Should be checked if applying any color to any component also replicates this.

Minimal config

lualine.sections.lualine_b = {'signify'}

pic-window-210221-1739-14

Bug: filetype component doesn't update the icon

Filetype component is stuck with the icon of the first file opened during the session.

As far as I can understand it is due to "caching" of the result of icon query:

if ok and not options.icon then
  local f_name,f_extension = vim.fn.expand('%:t'),vim.fn.expand('%:e')
  options.icon = devicons.get_icon(f_name,f_extension)
else
  ok = vim.fn.exists("*WebDevIconsGetFileTypeSymbol")
  if ok ~= 0 and not options.icon then
    options.icon = vim.fn.WebDevIconsGetFileTypeSymbol()
  end
end

I guess that such a caching was introduced to improve the performance. I think that correct implementation should save the filetype and the icon and update the icon when new filetype is different from the saved one. I can make a pull request if needed.

refactor all components with options

I would change this to look cleaner.

if options.colored == nil then options.colored = true end

and work with options variables. Similar to all other option variables.
This has two benefits

  • while looking at the code you instantly know that if options.colored refers to an option. if colored can be a local variable
  • no additional memory usage

Originally posted by @hoob3rt in #61 (comment)

This needs to be done on the whole codebase

cursor blinks very quickly

the cursor blinks very quickly in insert mode

Screen.Recording.2021-01-02.at.07.39.28.mov
my config
return function()
  local lualine = require('lualine')
  lualine.theme = 'gruvbox'
  lualine.separator = '/'
  lualine.sections = {
    lualine_a = { 'mode' },
    lualine_b = { 'filename' },
    lualine_c = {  },
    lualine_x = {  },
    lualine_y = { 'branch' },
    lualine_z = { 'filetype'  },
    lualine_diagnostics = {  }
  }
  lualine.inactiveSections = {
    lualine_a = { 'mode' },
    lualine_b = { 'filename' },
    lualine_c = {  },
    lualine_x = {  },
    lualine_y = { 'branch' },
    lualine_z = { },
    lualine_diagnostics = {  }
  }
  lualine.extensions = { 'fzf' }
  lualine.status()
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.