nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When I bookmark files no icons come up after updating

wakywayne opened this issue · comments

Please note the bookmark functionality is working, but I am blind to what files I am book marking.

Description

This should be an easy fix I just need to know how to add a custom icon for that specific thing, but I can't find the name for the icons.

I use some custom icons already here:

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

 -- local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
 -- if not config_status_ok then
 --   return
 -- end

-- local tree_cb = nvim_tree_config.nvim_tree_callback
local api = require("nvim-tree.api")

local function edit_or_open()
  local node = api.tree.get_node_under_cursor()

  if node.nodes ~= nil then
    -- expand or collapse folder
    api.node.open.edit()
  else
    -- open file
    api.node.open.edit()
    -- Close the tree if file was opened
    api.tree.close()
  end
end

-- open as vsplit on current node
local function vsplit_preview()
  local node = api.tree.get_node_under_cursor()

  if node.nodes ~= nil then
    -- expand or collapse folder
    api.node.open.edit()
  else
    -- open file as vsplit
    api.node.open.vertical()
  end

  -- Finally refocus on tree if it was lost
  api.tree.focus()
end


 local function my_on_attach(bufnr)
    local api = require "nvim-tree.api"

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

    -- default mappings
    api.config.mappings.default_on_attach(bufnr)

    -- custom mappings
    vim.keymap.set("n", "l", edit_or_open,          opts("Edit Or Open"))
    vim.keymap.set("n", "L", vsplit_preview,        opts("Vsplit Preview"))
    vim.keymap.set("n", "h", api.tree.collapse_all,        opts("Collapse All"))
    vim.keymap.set("n", "H", api.tree.close, opts("Close"))
  end

nvim_tree.setup {
on_attach = my_on_attach,
  update_focused_file = {
    enable = true,
    update_cwd = true,
  },
  renderer = {
    root_folder_modifier = ":t",
    icons = {
      glyphs = {
        default = "",
        symlink = "",
        folder = {
          arrow_open = "",
          arrow_closed = "",
          default = "",
          open = "",
          empty = "",
          empty_open = "",
          symlink = "",
          symlink_open = "",
        },
        git = {
          unstaged = "",
          staged = "S",
          unmerged = "",
          renamed = "",
          untracked = "U",
          deleted = "",
          ignored = "",
        },
      },
    },
  },
  diagnostics = {
    enable = true,
    show_on_dirs = true,
    icons = {
      hint = "",
      info = "",
      warning = "",
      error = "",
    },
  },
  view = {
    width = 30,
    side = "left",
    -- mappings = {
      -- list = {
        -- { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
        -- { key = "h", cb = tree_cb "close_node" },
        -- { key = "v", cb = tree_cb "vsplit" },
      -- },
    -- },
  },
}

Neovim version

NVIM 0.10.0

Operating system and version

WSL linux

Windows variant

WSL

nvim-tree version

current

Clean room replication

// couldn't find the file

Steps to reproduce

If you are able to customize the bookmark icon to anything then that will solve my issue I just need to now how to customize what the bookmark icon should look like ill make it the letter m idc.

Expected behavior

No response

Actual behavior

No response

I couldn't replicate with your configuration.

See :help nvim-tree-opts-renderer

Examples to set and customise bookmark icon and highlight:

require("nvim-tree").setup({
  renderer = {
    highlight_bookmarks = "name",
    icons = {
      show = {
        bookmarks = true,
      },
      bookmarks_placement = "after",
      glyphs = {
        bookmark = "B",
      },
    },
  },
})

vim.cmd([[
:hi NvimTreeBookmarkIcon guifg=yellow guibg=red
:hi NvimTreeBookmarkHL guifg=black guibg=green
]])

@alex-courtis thank you that worked