nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

web-devicons default not used

alex-courtis opened this issue · comments

Description

Help states that the default nvim-web-devicons icon will be used for files.

            *nvim-tree.renderer.icons.web_devicons.file.enable*
            Show icons on files.
            Overrides |nvim-tree.renderer.icons.glyphs.default|
              Type: `boolean`, Default: `true`

        *nvim-tree.renderer.icons.glyphs.default*
        Glyph for files.
        Overridden by |nvim-tree.renderer.icons.web_devicons| if available.
          Type: `string`, Default: `""`

glyphs.default is always used

Neovim version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202

Operating system and version

Linux 6.8.7-arch1-1

Windows variant

No response

nvim-tree version

5a18b98

Clean room replication

local M = {}

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

vim.opt.termguicolors = true
vim.opt.cursorline = true

vim.opt.statusline = "b%{bufnr()} w%{winnr()} i%{win_getid()} %y %F"

vim.o.packpath = "/tmp/nd/site"
local package_root = vim.o.packpath .. "/pack"
local install_path = vim.o.packpath .. "/pack/packer/start/packer.nvim"
local compile_path = vim.o.packpath .. "/pack/packer/start/packer.nvim/plugin/packer_compiled.lua"

local bootstrapping = vim.fn.isdirectory(install_path) == 0

if bootstrapping then
  print("Bootstrapping...")
  vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end

local packer = require("packer")

packer.init({
  package_root = package_root,
  compile_path = compile_path,
})

packer.use("wbthomason/packer.nvim")
packer.use({
  "neovim/nvim-lspconfig",
  "nvim-tree/nvim-web-devicons",
  -- "/home/alex/src/nvim-web-devicons/449-default-icon-not-shown",
  'nvim-tree/nvim-tree.lua',
  -- "/home/alex/src/nvim-tree/master",
})

if bootstrapping then
  vim.cmd([[
    autocmd User PackerComplete quitall
  ]])

  packer.sync()
  return
end

local api = require("nvim-tree.api")

-- stylua: ignore start
vim.keymap.set("n", ";",        ":",                                   { noremap = true })
vim.keymap.set("n", "<space>a", function() api.tree.open({}) end,      { noremap = true })
vim.keymap.set("n", "<space>'", function() api.tree.find_file({}) end, { noremap = true })
vim.keymap.set("n", "<space>o", function() vim.cmd.wincmd("p") end,    { noremap = true })
-- stylua: ignore end

function M.on_attach(bufnr)
  local function opts(desc)
    return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
  end

  api.config.mappings.default_on_attach(bufnr)

  -- stylua: ignore start
  vim.keymap.set('n', '?',     api.tree.toggle_help,                  opts('Help'))
  -- stylua: ignore end
end
require("nvim-web-devicons").set_default_icon('W', '#89e051', 113)

require("nvim-tree").setup({
  on_attach = M.on_attach,
  hijack_cursor = false,
  auto_reload_on_write = true,
  disable_netrw = false,
  hijack_netrw = true,
  hijack_unnamed_buffer_when_opening = false,
  root_dirs = {},
  prefer_startup_root = false,
  sync_root_with_cwd = false,
  reload_on_bufenter = false,
  respect_buf_cwd = false,
  select_prompts = false,
  sort = {
    sorter = "name",
    folders_first = true,
    files_first = false,
  },
  view = {
    centralize_selection = false,
    cursorline = true,
    debounce_delay = 15,
    side = "left",
    preserve_window_proportions = false,
    number = false,
    relativenumber = false,
    signcolumn = "yes",
    width = 30,
    float = {
      enable = false,
      quit_on_focus_loss = true,
      open_win_config = {
        relative = "editor",
        border = "rounded",
        width = 30,
        height = 30,
        row = 1,
        col = 1,
      },
    },
  },
  renderer = {
    add_trailing = false,
    group_empty = false,
    full_name = false,
    root_folder_label = ":~:s?$?/..?",
    indent_width = 2,
    special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
    symlink_destination = true,
    highlight_git = "none",
    highlight_diagnostics = "none",
    highlight_opened_files = "none",
    highlight_modified = "none",
    highlight_bookmarks = "none",
    highlight_clipboard = "name",
    indent_markers = {
      enable = false,
      inline_arrows = true,
      icons = {
        corner = "",
        edge = "",
        item = "",
        bottom = "",
        none = " ",
      },
    },
    icons = {
      web_devicons = {
        file = {
          enable = true,
          color = true,
        },
        folder = {
          enable = false,
          color = true,
        },
      },
      git_placement = "before",
      modified_placement = "after",
      diagnostics_placement = "signcolumn",
      bookmarks_placement = "signcolumn",
      padding = " ",
      symlink_arrow = "",
      show = {
        file = true,
        folder = true,
        folder_arrow = true,
        git = true,
        modified = true,
        diagnostics = true,
        bookmarks = true,
      },
      glyphs = {
        default = "N",
        symlink = "",
        bookmark = "󰆤",
        modified = "",
        folder = {
          arrow_closed = "",
          arrow_open = "",
          default = "",
          open = "",
          empty = "",
          empty_open = "",
          symlink = "",
          symlink_open = "",
        },
        git = {
          unstaged = "",
          staged = "",
          unmerged = "",
          renamed = "",
          untracked = "",
          deleted = "",
          ignored = "",
        },
      },
    },
  },
  hijack_directories = {
    enable = true,
    auto_open = true,
  },
  update_focused_file = {
    enable = false,
    update_root = {
      enable = false,
      ignore_list = {},
    },
    exclude = false,
  },
  system_open = {
    cmd = "",
    args = {},
  },
  git = {
    enable = true,
    show_on_dirs = true,
    show_on_open_dirs = true,
    disable_for_dirs = {},
    timeout = 400,
    cygwin_support = false,
  },
  diagnostics = {
    enable = true,
    show_on_dirs = false,
    show_on_open_dirs = true,
    debounce_delay = 50,
    severity = {
      min = vim.diagnostic.severity.HINT,
      max = vim.diagnostic.severity.ERROR,
    },
    icons = {
      hint = "",
      info = "",
      warning = "",
      error = "",
    },
  },
  modified = {
    enable = false,
    show_on_dirs = true,
    show_on_open_dirs = true,
  },
  filters = {
    enable = true,
    git_ignored = true,
    dotfiles = false,
    git_clean = false,
    no_buffer = false,
    no_bookmark = false,
    custom = {},
    exclude = {},
  },
  live_filter = {
    prefix = "[FILTER]: ",
    always_show_folders = true,
  },
  filesystem_watchers = {
    enable = true,
    debounce_delay = 50,
    ignore_dirs = {},
  },
  actions = {
    use_system_clipboard = true,
    change_dir = {
      enable = true,
      global = false,
      restrict_above_cwd = false,
    },
    expand_all = {
      max_folder_discovery = 300,
      exclude = {},
    },
    file_popup = {
      open_win_config = {
        col = 1,
        row = 1,
        relative = "cursor",
        border = "shadow",
        style = "minimal",
      },
    },
    open_file = {
      quit_on_open = false,
      eject = true,
      resize_window = true,
      window_picker = {
        enable = true,
        picker = "default",
        chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
        exclude = {
          filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
          buftype = { "nofile", "terminal", "help" },
        },
      },
    },
    remove_file = {
      close_window = true,
    },
  },
  trash = {
    cmd = "gio trash",
  },
  tab = {
    sync = {
      open = false,
      close = false,
      ignore = {},
    },
  },
  notify = {
    threshold = vim.log.levels.INFO,
    absolute_path = true,
  },
  help = {
    sort_by = "key",
  },
  ui = {
    confirm = {
      remove = true,
      trash = true,
      default_yes = false,
    },
  },
  experimental = {},
  log = {
    enable = true,
    truncate = true,
    types = {
      all = false,
      config = false,
      copy_paste = false,
      dev = true,
      diagnostics = false,
      git = false,
      profile = false,
      watcher = false,
    },
  },
})

return M

Steps to reproduce

/usr/bin/nvim -nu /tmp/nd/nd.lua

:NvimTreeOpen

Expected behavior

Default files have icon W

Actual behavior

Default files have icon N

@sethen

I'd be most grateful if you tested this fix #2758

cd /path/to/nvim-tree.lua
git pull
git checkout 2758-use-web-devicons-default

When you're finished testing:

git checkout master

@sethen

I'd be most grateful if you tested this fix #2758

cd /path/to/nvim-tree.lua
git pull
git checkout 2758-use-web-devicons-default

When you're finished testing:

git checkout master

Happy to test this but unsure I know how. I am using Lazy to install the web-devicons plugin. Any guidance would be helpful here.

: ; find ~ -name nvim-web-devicons -type d 2>/dev/null
/home/alex/.local/share/nvim/site/pack/packer/start/nvim-web-devicons
...
cd /home/alex/.local/share/nvim/site/pack/packer/start/nvim-web-devicons
git pull
git checkout 2758-use-web-devicons-default

Alternatively, you could direct lazy to use the branch instead of master. Check the lazy doc...

Never mind branch testing @sethen , the PR has been merged.

I'd be most grateful if you updated to latest and tested that.