Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple status bars will show wrong title when navigating between windows #26

Closed
martin-braun opened this issue Oct 10, 2022 · 6 comments

Comments

@martin-braun
Copy link

martin-braun commented Oct 10, 2022

Putting vim.opt.laststatus = 2 to have window based status bars (instead of a global one) reveals an issue when navigating between the windows:

2022-10-09.12.01.59.AM.mp4

Both window status bars display the same file name / title.

@martin-braun martin-braun changed the title Statusbar Multiple status bars will show wrong title when navigating between them Oct 10, 2022
@martin-braun martin-braun changed the title Multiple status bars will show wrong title when navigating between them Multiple status bars will show wrong title when navigating between windows Oct 10, 2022
@siduck
Copy link
Member

siduck commented Oct 11, 2022

i see this happens due to a function ( which prints current active buffer name )

@siduck
Copy link
Member

siduck commented Nov 13, 2022

i removed that commit as it was showing same file icons on multiple statusbars. If you are fine without fileicon then you can try this

["NvChad/ui"] = {
    override_options = {
      statusline = {
        overriden_modules = function()
          return {
            fileInfo = function()
              local filename = (vim.fn.expand "%" == "" and " Empty") or " %t "
              return "%#St_file_info#" .. filename .. "%#St_file_sep#" .. ""
            end,
          }
        end,
      },
    },
  }
  • If "%t" is returned by the fileInfo function then statusline doesnt show same filenames in multiple statusbars.

  • Before we were using vim.fn.expand("%:t") which just prints currently focused filename, this is ok with global statusline but not with multiple statusbars.

  • So if we use vim.fn.expand("%:t") as a parameter for the devicons function ( this function generates file icon based on parameters like filename, file type etc ) So this will just generate fileicon of currently focused buffer which isnt good for multiple statusbars.

@siduck siduck closed this as completed Nov 13, 2022
@martin-braun
Copy link
Author

@siduck Thank you for looking into this. It's unfortunate that I lose the icon in the process, but it's actually more worth to have a proper status bar for each window than having an icon, so I really appreciate your solution, it works like charm! =)

Good job!

@siduck
Copy link
Member

siduck commented Nov 14, 2022

@martin-braun there might be a way to get the icon too i think!

Can you try any statusline plugin and with laststatus=2 and see if they have working icons on multiple bars?

%t is some ststusline stuff and gets evaluated by the statusline so we don't have to generate filename by some functions. This fixed your issue of same filename showing on multiple bars but we need to find a way to show the icon too :(

@martin-braun
Copy link
Author

@siduck lualine seems to show their icon (and a lot of other information) only from the active buffer on the current window.

@sunaku
Copy link

sunaku commented Aug 16, 2023

The code snippet provided in #26 (comment) is out of date. 😥 I had to update it, per nvchad_ui v2.0 documentation, as follows:

M.ui = {
  -- https://github.com/NvChad/NvChad/discussions/2233
  -- https://github.com/NvChad/ui/issues/26#issuecomment-1312632083
  -- https://nvchad.com/docs/config/nvchad_ui#override_statusline_modules
  statusline = {
    overriden_modules = function(modules)
      modules[2] = (function()
        local filename = (vim.fn.expand "%" == "" and " Empty") or " %t "
        return "%#St_file_info#" .. filename .. "%#St_file_sep#" .. ""
      end)()
    end,
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants