utilyre / barbecue.nvim

Visual Studio Code inspired breadcrumbs plugin for the Neovim editor
MIT License
776 stars 31 forks source link

[BUG]: exclude_filetypes are not respected immediately in some cases #92

Open botbotty opened 11 months ago

botbotty commented 11 months ago

Requirements

Expected Behavior

  1. Use nvim-neo-tree/neo-tree.nvim to open a file, the filetype of which is "excluded" in barbecue config. Winbar should not show up for this file.
  2. Use akinsho/toggleterm.nvim to open a terminal, and filetype "toggleterm" is also excluded. Winbar should not show up too.

Actual Behavior

  1. Use nvim-neo-tree/neo-tree.nvim to open a file, the filetype of which is "excluded" in barbecue config. Winbar shows up for this file, and then disappear when I move the cursor or enter-then-leave insert mode.
  2. Use akinsho/toggleterm.nvim to open a terminal, and filetype "toggleterm" is also excluded. Winbar show up, and disappear when I leave terminal mode or hide-then-show-again the terminal.

Neovim Version

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info

Minimal Configuration

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme!
  "folke/tokyonight.nvim",

  {
    "utilyre/barbecue.nvim",
    dependencies = {
      "neovim/nvim-lspconfig",
      "SmiteshP/nvim-navic",
      "nvim-tree/nvim-web-devicons",
    },
    opts = {
      exclude_filetypes = {
        "lua",
        "toggleterm",
      },
    },
  },
  {
    -- File Browser
    "nvim-neo-tree/neo-tree.nvim",
    dependencies = {
      "nvim-tree/nvim-web-devicons",
      "nvim-lua/plenary.nvim",
      "MunifTanjim/nui.nvim",
    },
    branch = "v3.x",
  },
  {
    -- Terminal
    "akinsho/toggleterm.nvim",
    version = "*",
    opts = {
      open_mapping = "<C-T>",
    }
  }
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme!
vim.cmd([[colorscheme tokyonight]])

Reproduction

case 1

  1. nvim -u repro.lua
  2. :Neotree to show the file browser
  3. Double click "repro.lua" in the file browser
  4. repro.lua is opened, and winbar show up
  5. Press "j" to move the cursor
  6. winbar disappear

case 2

  1. nvim -u repro.lua
  2. Press Ctrl+T to open a terminal, winbar shows
  3. Press Ctrl+\ Ctrl+N to quit terminal mode, winbar disappears
vieko commented 9 months ago

👋🏼 in the case of toggleterm, filetypes are not respected when starts_in_insert is set to true on toggleterm's configuration.

The following works as expected:

require("toggleterm").setup({
  size = function(term)
    if term.direction == "horizontal" then
      return 15
    elseif term.direction == "vertical" then
      return vim.o.columns * 0.4
    else
      return 20
    end
  end,
  hide_numbers = true,
  shade_terminals = false,
  start_in_insert = false,
  persist_size = true,
})
require("barbecue").setup({
  theme = "catppuccin",
  show_navic = true,
  show_dirname = false,
  show_modified = false,
  context_follow_icon_color = true,
  exclude_filetypes = { "toggleterm" },
})
vhqkze commented 9 months ago

@vieko When using toggleterm, I have the same issue. When I try the method you suggested by setting start_in_insert to false, it does solve the problem, but I still need to manually enter insert mode.

In fact, I found that modifying the on_open function can also solve the issue of displaying the winbar, without changing start_in_insert:

on_open = function(term)
    vim.defer_fn(function()
        vim.wo[term.window].winbar = ""
    end, 0)
end

I tried that if vim.defer_fn is not used, it will not work, so vim.defer_fn is necessary.

poscat0x04 commented 4 months ago

Same can be achieved by doing an UI update on TermEnter:

vim.api.nvim_create_autocmd('TermEnter',
{ callback = function() require('barbecue.ui').update() end })