j-morano / buffer_manager.nvim

A simple plugin to easily manage Neovim buffers.
MIT License
232 stars 12 forks source link

Is there a way to change the window border color? #26

Closed leiswatch closed 1 year ago

leiswatch commented 1 year ago

Hi, I tried to change the window border color with the highlight property as stated in documentation, but it changes the color of buffer names, not the border. Is there any other way to do this?

j-morano commented 1 year ago

Hello. You are completely right. Thank you for the feedback. I added a commit solving the issue. Now, to change the border colors, should be enough to add highlight = "Normal:YourCustomHighlight" to your setup options. Of course, feel free to reopen the issue if the problem persists.

leiswatch commented 1 year ago

@j-morano thanks for the quick response, but I think you broke the plugin completely with that change, because now I'm getting this error whenever I open buffer manager

E5108: Error executing lua .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:389: Vim:E5248: Invalid character in group name
stack traceback:
        [C]: in function 'nvim_win_set_option'
        .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:389: in function 'create'
        .../nvim/lazy/buffer_manager.nvim/lua/buffer_manager/ui.lua:68: in function 'create_window'
        .../nvim/lazy/buffer_manager.nvim/lua/buffer_manager/ui.lua:277: in function 'toggle_quick_menu'
        [string ":lua"]:1: in main chunk

This is my config:

require("buffer_manager").setup({
  short_file_names = false,
  short_term_names = true,
  width = 0.75,
  borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" },
})
j-morano commented 1 year ago

I cannot replicate. Have you the latest version of plenary?

leiswatch commented 1 year ago

@j-morano I managed to find the cause of it, commenting out this if statement https://github.com/j-morano/buffer_manager.nvim/blob/1a7f7c845bb51ff62090cf279605a5ae77d81a9e/lua/buffer_manager/ui.lua#L65 fixes the issue that I'm having and everything works as expected.

I am using the latest version of plenary.

j-morano commented 1 year ago

Glad that it is working now for you. I do not know where the problem comes from. Thank you for posting the solution, in case someone else faces the same problem.

leiswatch commented 1 year ago

After looking at the code of buffer_manager plugin and plenary, I am surprised that it works for you, because in buffer_manager ui.lua there is

  if config.highlight ~= "" then
    win_config["highlight"] = config.highlight
  end
  local Buffer_manager_win_id, win = popup.create(bufnr, win_config)

  if config.highlight ~= "" then
    vim.api.nvim_set_option_value(
      "winhighlight",
      config.highlight,
      { win = win.border.win_id }
    )
  end

However, in plenary popup.create method, there is this piece of code

  if vim_options.highlight then
    vim.api.nvim_win_set_option(
      win_id,
      "winhl",
      string.format("Normal:%s,EndOfBuffer:%s", vim_options.highlight, vim_options.highlight)
    )
  end

So highlight = "Normal:Normal" is incompatible with vim.api.nvim_win_set_option in plenary popup.create and highlight = Normal is incompatible with vim.api.nvim_set_option_value from buffer manager ui.lua

j-morano commented 1 year ago

True. Weird that it was working on all my machines. I added another commit removing the if statement that you mentioned. Thank you so much for investigating the issue.

leiswatch commented 1 year ago

No problem, glad that I could help. Thanks for this awesome plugin!