nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.87k stars 224 forks source link

BUG: Disable foldcolumn of statuscol #1464

Closed hungvx-dev closed 5 months ago

hungvx-dev commented 6 months ago

Did you check docs and existing issues?

Neovim Version (nvim -v)

0.9.5

Operating System / Version

MacOS 14.4.1

Describe the Bug

I want to disable foldcolumn when use: https://github.com/luukvbaal/statuscol.nvim, https://github.com/kevinhwang91/nvim-ufo for setting statuscolumn.

I had ingored neo-tree at statuscol config. But not working

{
    ft_ignore = { "neo-tree" },
   ....
}

Screenshots, Traceback

image

Steps to Reproduce

  1. Open neo-tree
  2. Open any filetype

Expected Behavior

Disable fold in neo-tree

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
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", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}

local neotree_config = {
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
  cmd = { "Neotree" },
  keys = {
    { "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
  },
  opts = {
    sources = { "filesystem", "buffers", "git_status", "document_symbols" },
    open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "Outline" },
    close_if_last_window = false,
    popup_border_style = "rounded",
    enable_git_status = true,
    enable_diagnostics = true,
    nesting_rules = {
      [""] = { "" },
    },
    default_component_configs = {
      indent = {
        with_expanders = nil,
        expander_collapsed = HVIM.icons.UI.Direction.Angle.Right,
        expander_expanded = HVIM.icons.UI.Direction.Angle.Down,
      },
      icon = {
        folder_closed = HVIM.icons.UI.Folder.Close,
        folder_open = HVIM.icons.UI.Folder.Open,
        folder_empty = HVIM.icons.UI.Folder.Empty,
        folder_empty_open = HVIM.icons.UI.Folder.EmptyOpen,
      },
      modified = {
        symbol = HVIM.icons.Git.LineModified,
      },
      git_status = {
        symbols = {
          -- Change type
          added = HVIM.icons.Git.LineAdded,
          modified = HVIM.icons.Git.LineModified,
          deleted = HVIM.icons.Git.LineRemoved,
          renamed = HVIM.icons.Git.LineRename,
          -- Status type
          untracked = HVIM.icons.Git.FileUntracked,
          ignored = HVIM.icons.Git.FileIgnored,
          unstaged = HVIM.icons.Git.FileUnstaged,
          staged = HVIM.icons.Git.FileStaged,
          conflict = HVIM.icons.Git.FileUnmerged,
        },
      },
    },
    commands = {
      copy_selector_path = function(state)
        local node = state.tree:get_node()
        local filepath = node:get_id()
        local filename = node.name
        local modify = vim.fn.fnamemodify

        local vals = {
          ["1"] = modify(filepath, ":."),
          ["2"] = filename,
          ["3"] = modify(filepath, ":~"),
          ["4"] = filepath,
        }

        local options = vim.tbl_filter(function(val)
          return vals[val] ~= ""
        end, vim.tbl_keys(vals))
        if vim.tbl_isempty(options) then
          vim.notify("No values to copy", vim.log.levels.WARN)
          return
        end
        table.sort(options)
        vim.ui.select(options, {
          prompt = "Choose to copy to clipboard:",
          format_item = function(item)
            return ("%s: %s"):format(item, vals[item])
          end,
        }, function(choice)
          local result = vals[choice]
          if result then
            vim.notify(("Copied: `%s`"):format(result))
            vim.fn.setreg("+", result)
          end
        end)
      end,
    },
    filesystem = {
      follow_current_file = {
        enabled = true,
        leave_dirs_open = true,
      },
      group_empty_dirs = false,
      use_libuv_file_watcher = true,
      filtered_items = {
        never_show = {
          ".DS_Store",
        },
      },
      window = {
        mapping_options = {
          noremap = true,
          nowait = true,
        },
        mappings = {
          -- ["<space>"] = "none",
          ["A"] = "command_b",
          ["Y"] = "copy_selector_path",
          ["<C-x>"] = "split_with_window_picker",
          ["<C-v>"] = "vsplit_with_window_picker",
          ["o"] = { "open", nowait = true },
        },
      },
      fuzzy_finder_mappings = {
        ["<C-j>"] = "move_cursor_down",
        ["<C-k>"] = "move_cursor_up",
      },
    },
    buffers = {
      follow_current_file = {
        enabled = true,
        leave_dirs_open = true,
      },
      group_empty_dirs = false,
      show_unloaded = true,
      window = {
        mappings = {
          ["."] = "set_root",
          ["<bs>"] = "navigate_up",
        },
      },
    },
    window = {
      position = "right",
      width = 40,
      mappings = {},
    },
  },
}

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

vim.cmd.colorscheme("tokyonight")
-- add anything else here

-- For statuscol ---------
local M = {}

function M.setup()
  local present, statuscol = pcall(require, "statuscol")
  if not present then
    return
  end
  local builtin = require("statuscol.builtin")
  M.opts = {
    ft_ignore = { "neo-tree" },
    bt_ignore = { "terminal" },
    segments = {
      { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
      { text = { "%s" }, click = "v:lua.ScSa" },
      {
        text = { "", builtin.lnumfunc, " " },
        condition = { true, builtin.not_empty },
        click = "v:lua.ScLa",
      },
    },
  }

  statuscol.setup(M.opts)
end

return M
lucasquin commented 5 months ago
{
    ft_ignore = { "neo-tree", "neotree" },
   ....
}

Works for me

hungvx-dev commented 5 months ago

I found the solution by following https://github.com/kevinhwang91/nvim-ufo/issues/33#issuecomment-1664656433