nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.24k stars 609 forks source link

Statuscolumn is not unset for nvim-tree's buffer #2249

Closed WhiteBlackGoose closed 1 year ago

WhiteBlackGoose commented 1 year ago

Description

I set statuscolumn, but it affected nvim-tree too

image

Neovim version

NVIM v0.10.0-dev-2028d1e
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

NixOS unstable

nvim-tree version

e2a4c9d09d205ebe5f071264f43f73a0077c43a3

Minimal config

Note: all I did is adding

vim.o.statuscolumn = "hello"

in the end

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {}
end

vim.o.statuscolumn = "hello"

Steps to reproduce

  1. nvim -u nvt-min.lua
  2. :NvimTreeOpen
  3. See

Expected behavior

It should unset it for its buffer, I think

Actual behavior

It keeps the statuscolumn

WhiteBlackGoose commented 1 year ago

Fix

local id = vim.api.nvim_create_augroup("StatusCol", {})
vim.api.nvim_create_autocmd({"FileType", "BufEnter"}, {
  group = id,
  callback = function()
    if vim.api.nvim_buf_get_option(0, "ft") == "NvimTree" then
      vim.opt_local.statuscolumn = ""
    end
  end,
})
gegoune commented 1 year ago

It does what you asked it to do. Not sure if we can do anything here without potentially breaking other set ups.

WhiteBlackGoose commented 1 year ago

If it's by design, feel free to close it