Skip to content

[Bug]: offset not working for NvimTree #1048

@fzl-22

Description

@fzl-22

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The issue is that when the NvimTree is opened, it not create an offset for the file explorer.

Image

What did you expect to happen?

Expected behaviour is the NvimTree is separated with other tabs in bufferline.

Config

lua/configs/bufferline.lua:

llocal bufferline_ok, bufferline = pcall(require, "bufferline")
if not bufferline_ok then
	return
end

bufferline.setup({
	options = {
		numbers = "none", 
		close_command = "Bdelete! %d", 
		right_mouse_command = "Bdelete! %d", 
		left_mouse_command = "buffer %d", 
		middle_mouse_command = nil, 
		indicator_icon = "",
		buffer_close_icon = "",
		modified_icon = "",
		close_icon = "",
		left_trunc_marker = "",
		right_trunc_marker = "",
		max_name_length = 30,
		max_prefix_length = 30, 
		tab_size = 21,
		diagnostics = "nvim_lsp", 
		diagnostics_indicator = function(count, level, diagnostics_dict, context)
			local icon = level:match("error") and "" or ""
			return " " .. icon .. count
		end,
		update_in_insert = true,
		offsets = {
			{
				filetype = "NvimTree",
				text = "File Explorer",
        text_align = "left",
        separator = true,
			},
		},
		show_buffer_icons = true,
		show_buffer_close_icons = true,
		show_close_icon = true,
		show_tab_indicators = true,
		persist_buffer_sort = true, 
		separator_style = "thin", 
		enforce_regular_tabs = true,
		always_show_bufferline = true,
	},
	highlights = require("catppuccin.special.bufferline").get_theme(),
})

lua/configs/nvim_tree.lua:

-- following options are the default
-- each of these are documented in `:help nvim-tree.OPTION_NAME`

local nvim_tree_ok, nvim_tree = pcall(require, "nvim-tree")
if not nvim_tree_ok then
	return
end

nvim_tree.setup({
	disable_netrw = true,
	hijack_netrw = true,
	open_on_tab = false,
	hijack_cursor = true,
	update_cwd = true,
	hijack_directories = {
		enable = true,
		auto_open = true,
	},
	filters = {
		dotfiles = false,
	},
	diagnostics = {
		enable = true,
		icons = {
			hint = "",
			info = "",
			warning = "",
			error = "",
		},
	},
	update_focused_file = {
		enable = true,
		update_cwd = true,
		ignore_list = {},
	},
	git = {
		enable = true,
		ignore = false,
		timeout = 500,
	},
	view = {
		width = 30,
		side = "left",
		number = false,
		relativenumber = false,
		preserve_window_proportions = true,
	},
	renderer = {
		highlight_git = true,
		root_folder_modifier = ":t",
		indent_markers = { enable = true },
		icons = {
			show = {
				file = true,
				folder = true,
				folder_arrow = true,
				git = true,
			},
			glyphs = {
				default = "",
				symlink = "",
				git = {
					unstaged = "",
					staged = "S",
					unmerged = "",
					renamed = "",
					deleted = "",
					untracked = "U",
					ignored = "",
				},
				folder = {
					default = "",
					open = "",
					empty = "",
					empty_open = "",
					symlink = "",
				},
			},
		},
	},
})

Full configurations: https://github.com/fzl-22/zielisme.nvim

Additional Information

When running :echo &filetype, the output is NvimTree which is the exact string of the filetype value:

Image

commit

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions