nvim-neo-tree / neo-tree.nvim

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

How to disable icons? #998

Closed nizamiza closed 1 year ago

nizamiza commented 1 year ago

I'm pretty sure this worked a while ago, but I can't seem to be able to disable icons on a fresh install of LazyVim with NeoTree. Here is my config:

NeoTree config ```lua return { "nvim-neo-tree/neo-tree.nvim", dependencies = { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim" }, keys = { { "nt", "Neotree toggle", desc = "Toggle file tree" }, { "nf", "Neotree focus", desc = "Focus file tree" } }, opts = { close_if_last_window = true, default_component_configs = { icon = { folder_closed = "+", folder_open = "-", folder_empty = "%", default = "" }, git_status = { symbols = { deleted = "", renamed = "", modified = "", untracked = "", ignored = "", unstaged = "", staged = "", conflict = "" } } }, document_symbols = { kinds = { File = { icon = "", hl = "Tag" }, Namespace = { icon = "", hl = "Include" }, Package = { icon = "", hl = "Label" }, Class = { icon = "", hl = "Include" }, Property = { icon = "", hl = "@property" }, Enum = { icon = "", hl = "@number" }, Function = { icon = "", hl = "Function" }, String = { icon = "", hl = "String" }, Number = { icon = "", hl = "Number" }, Array = { icon = "", hl = "Type" }, Object = { icon = "", hl = "Type" }, Key = { icon = "", hl = "" }, Struct = { icon = "", hl = "Type" }, Operator = { icon = "", hl = "Operator" }, TypeParameter = { icon = "", hl = "Type" }, StaticMethod = { icon = " ", hl = "Function" } } }, filesystem = { follow_current_file = true, filtered_items = { visible = true, hide_dotfiles = false, hide_gitignored = false } }, buffers = { follow_current_file = true } } } ```

And here is how I see icons:

Screenshot Screenshot 2023-06-18 at 20 04 47
Item Version
NeoTree 2.64.0
NeoVim 0.9.1
LazyVim 4.9.0
OS macOS 13.4
Terminal emulator Alacritty
soifou commented 1 year ago

You can achieve what you want by tweaking the icon component. For instance, to get rid off the file icons:

filesystem = {
    components = {
        icon = function(config, node, state)
            if node.type == 'file' then return {} end
            return require('neo-tree.sources.common.components').icon(config, node, state)
        end,
    },
},
nizamiza commented 1 year ago

You can achieve what you want by tweaking the icon component. For instance, to get rid off the file icons:

filesystem = {
    components = {
        icon = function(config, node, state)
            if node.type == 'file' then return {} end
            return require('neo-tree.sources.common.components').icon(config, node, state)
        end,
    },
},

It worked for the file icons, but I think it's still using icons for the folder collapse/expand:

Screenshot Screenshot 2023-06-19 at 16 48 10

Here is my updated config:

NeoTree config ```lua return { "nvim-neo-tree/neo-tree.nvim", dependencies = { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim" }, keys = { { "nt", "Neotree toggle", desc = "Toggle file tree" }, { "nf", "Neotree focus", desc = "Focus file tree" } }, opts = { close_if_last_window = true, default_component_configs = { icon = { folder_closed = "+", folder_open = "-", folder_empty = "%", default = "" }, git_status = { symbols = { deleted = "", renamed = "", modified = "", untracked = "", ignored = "", unstaged = "", staged = "", conflict = "" } } }, filesystem = { follow_current_file = true, filtered_items = { visible = true, hide_dotfiles = false, hide_gitignored = false }, components = { icon = function(config, node, state) if node.type == "file" then return {} end return require("neo-tree.sources.common.components").icon(config, node, state) end } }, buffers = { follow_current_file = true } } } ```
nizamiza commented 1 year ago

Ok, I got rid of those as well by setting the expander_collapsed and expander_expanded options of the indent node to custom values. Using the default config helped in finding this (:lua require("neo-tree").paste_default_config()).

I will leave my config for iconless NeoTree here, in case somebody needs it in the future.

NeoTree config without icons ```lua return { "nvim-neo-tree/neo-tree.nvim", dependencies = { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim" }, keys = { { "nt", "Neotree toggle", desc = "Toggle file tree" }, { "nf", "Neotree focus", desc = "Focus file tree" } }, opts = { close_if_last_window = true, default_component_configs = { indent = { expander_collapsed = "+", expander_expanded = "-" }, git_status = { symbols = { deleted = "", renamed = "", modified = "", untracked = "", ignored = "", unstaged = "", staged = "", conflict = "" } } }, filesystem = { follow_current_file = true, components = { icon = function(config, node, state) if node.type == "file" or node.type == "directory" then return {} end return require("neo-tree.sources.common.components").icon(config, node, state) end } }, buffers = { follow_current_file = true } } } ```
9mm commented 1 year ago

Hey @soifou this is awesome, but i have one further question... i love how it looks by default if you dont have dev icons installed, with a blue * mark before the filename

How can I get this back, with the astricks being colored like the default?

Unfortunately i have to have dev icons for other parts of my config in one area where i need it, so i cant leave it disabled, but when its enabled it activates it for neo-tree

soifou commented 1 year ago

@9mm, I guess this should work:

icon = function(config, node, state)
    if node.type == 'file' then
        return {
            text = "* ",
            highlight = config.highlight,
        }
    end
    return require('neo-tree.sources.common.components').icon(config, node, state)
end,
9mm commented 1 year ago

dude......... awesome........ thank you

image
mgutz commented 2 months ago

Slight update to @soifou snippet, to remove folder and file icons

filesystem = {
    components = {
        icon = function(config, node, state)
            if node.type == 'file' or node.type == 'directory' then return {} end
            return require('neo-tree.sources.common.components').icon(config, node, state)
        end,
    },
}