Skip to content

Commit

Permalink
feat: refresh lualine based on timer + winbar support. (#736)
Browse files Browse the repository at this point in the history
* feat: refresh lualine based on timer.

* fix config test

* fix lag on win change issue

* handle errors in timer callback

* feat: add winbar support

Pull in winbar changes form pr #689 and adapt them
Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>

* make winbar disapear when winbar evals empty

* only update stl of curwin with globalstatus

* properly clear win local stl and wbr opts

* add version guards for winbar feature

* only add winbar if height > 1

* fix tests?

* refresh lualine on ModeChanged event

* ignore floating windows for refresh

* properply restore options to previous state

* fix stl not updating in cmd mode + some optimizations

* fix tests on <nvim-0.7

* merge status_dispatch & winbar_dispatch + winbar support for extensions

* fix globalstatus option not live updating

* update docs

* feat: allow disabling winbar and statusline separately

* fix tests

* fix: winbar some times oddly throwing errors

about not having space in floating windows.

This implements a temporary workaround the issue(neovim/neovim#19464)
until the bug in neovim gets fixed.

Co-authored-by: Diego Fujii <android.mxdiego9@gmail.com>
  • Loading branch information
shadmansaleh and diegodox authored Jul 22, 2022
1 parent 8d956c1 commit 53aa3d8
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 79 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,17 @@ require('lualine').setup {
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {},
disabled_filetypes = {
statusline = {},
winbar = {},
},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
Expand All @@ -142,6 +150,8 @@ require('lualine').setup {
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
```
Expand Down Expand Up @@ -336,13 +346,28 @@ options = {
theme = 'auto', -- lualine theme
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {}, -- Filetypes to disable lualine for.
disabled_filetypes = { -- Filetypes to disable lualine for.
statusline = {}, -- only ignores the ft for statusline.
winbar = {}, -- only ignores the ft for winbar.
},

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 refreash 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()
}
}
```

Expand Down Expand Up @@ -689,6 +714,34 @@ tabline = {
}
```

### Winbar
From neovim-0.8 you can customize your winbar with lualine.
Winbar configuration is similar to statusline.
```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 = {}
}
```
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 suported 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
Expand Down
Loading

13 comments on commit 53aa3d8

@ofseed
Copy link

@ofseed ofseed commented on 53aa3d8 Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit causes native Neovim startup messages to appear and disappear quickly, like a quick flash

2022-07-23.03-13-23.mp4

@ofseed
Copy link

@ofseed ofseed commented on 53aa3d8 Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also affect start screen plugins like alpha-nvim, the naive startup message quickly flashed before alpha-nvim is loaded.

@shadmansaleh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ofseed fixed in 6fbc35b

@MSDimos
Copy link

@MSDimos MSDimos commented on 53aa3d8 Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit causes that the statusline in the window of LeaderF will be replaced by my custom lualine. But if I configed like disabled_filetypes .statusline = {"leaderf"}, the statusline in the window of LeaderF will disappear, neither stausline of LeaderF nor my custom lualine displayed any more.

@plax-00
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why but this commit causes CursorHold autocommands to stop working.

@shadmansaleh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MSDimos maybe we're taking over the stl before leaderF is setting it's filetype option. I'll check it . Does leaderF expose what they want user to see in statusline so user can set it themselve? If they do you can easily use that to have a custom lualine extension.

@plax-00 We don't interact with CursorHold if CursorHold breaks after this it might be a bug in neovim. What autocommand did you have on CursorHold that stopped working ?

@shadmansaleh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plax-00 check if 2d6108e fixed your issue.

@shadmansaleh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MSDimos Your issue has been fixed in e9b05e7

@plax-00
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadmansaleh I have one for clearing the command line echo '' and one for LSP diagnostic floating windows lua vim.diagnostic.open_float().
I tried 2d6108e and the most recent commit (7888057) and it's still not working for me.

@shadmansaleh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plax-00 I can't reproduce it . Just tried adding a CursorHold auto command for vim.diagnostic.open_float() and it works fine.

@plax-00
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadmansaleh After changing around my settings, it seems like it has to do with updatetime. I had it set to 1000. At 995-997, CursorHold still works but takes much longer than a second. At 998, it took several minutes. I have it set to 990 now and it works fine, but it seems like this is messing with updatetime in some way.

@shadmansaleh
Copy link
Member Author

@shadmansaleh shadmansaleh commented on 53aa3d8 Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plax-00 It's because of this upstream issue neovim/neovim#12587 . It seems CursorHold and CursorHoldI events are broken with timers.

Try using https://github.com/antoinemadec/FixCursorHold.nvim as workaround . I've had it installed for so long that I even forgot what it did. That would explain why I couldn't reproduce the cursorhold issue.

@plax-00
Copy link

@plax-00 plax-00 commented on 53aa3d8 Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, thanks

Please sign in to comment.