barbecue.nvim
barbecue.nvim copied to clipboard
[BUG]: exclude_filetypes are not respected immediately in some cases
Requirements
- [X] I have skimmed other issues to see if this bug has already been reported.
- [X] I'm fully certain that this is not a breaking change, see the latest release.
- [X] This plugin and its dependencies are up to date with the latest commit.
- [ ] I'm willing to fix this through a PR.
Expected Behavior
- 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.
- Use akinsho/toggleterm.nvim to open a terminal, and filetype "toggleterm" is also excluded. Winbar should not show up too.
Actual Behavior
- 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.
- 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
-
nvim -u repro.lua
-
:Neotree
to show the file browser - Double click "repro.lua" in the file browser
- repro.lua is opened, and winbar show up
- Press "j" to move the cursor
- winbar disappear
case 2
-
nvim -u repro.lua
- Press Ctrl+T to open a terminal, winbar shows
- Press Ctrl+\ Ctrl+N to quit terminal mode, winbar disappears
👋🏼 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" },
})
@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.
Same can be achieved by doing an UI update on TermEnter
:
vim.api.nvim_create_autocmd('TermEnter',
{ callback = function() require('barbecue.ui').update() end })