Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Longest node may be calculated incorrectly #1639

Closed
3 tasks done
Kaiser-Yang opened this issue Dec 31, 2024 · 5 comments
Closed
3 tasks done

BUG: Longest node may be calculated incorrectly #1639

Kaiser-Yang opened this issue Dec 31, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Kaiser-Yang
Copy link

Kaiser-Yang commented Dec 31, 2024

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

0.10.1

Operating System / Version

WSL2 + Ubuntu 22.04 LTS

Describe the Bug

Setting all the require_width = 0, this will make all the components show when opening neo-tree, then use toggle_auto_expand_width, there will be some components don't show fully:

image

For the non-anscii characters, even if the window is wide enough, the caontainers' content will not be align correctly:

image

Screenshots, Traceback

No response

Steps to Reproduce

  1. Setting all the require_width = 0
  2. Open neo-tree
  3. Toggle auto expand width

Expected Behavior

Show the correct length.

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 = {
    -- Your config here
    -- ...
            use_default_mappings      = false,
            event_handlers            = {
                {
                    event = 'neo_tree_buffer_enter',
                    handler = function(_)
                        local mode = vim.api.nvim_get_mode().mode;
                        if mode == 'i' or mode == 'I' then
                            feedkeys('<esc>', 'n')
                        end
                        vim.wo.number = true
                        vim.wo.relativenumber = true
                        vim.wo.colorcolumn = ''
                    end
                },
            },
            default_component_configs = {
                git_status = {
                    width = 2,
                    align = 'left',
                },
                file_size = {
                    align = 'right',
                    required_width = 0,
                },
                last_modified = {
                    align = 'right',
                    required_width = 0,
                },
                symlink_target = {
                    enabled = true,
                    align = 'right',
                    required_width = 0,
                },
                created = {
                    enabled = true,
                    align = 'right',
                    required_width = 0,
                }
            },
            window                    = {
                width = '15%',
                mappings = {
                    ['e'] = 'toggle_auto_expand_width',
                }
            },
            renderers                 = {
                file = {
                    { 'indent' },
                    { 'icon' },
                    { 'git_status' },
                    { 'name' },
                    { 'diagnostics', errors_only = false },
                    { 'clipboard' },
                    {
                        'container',
                        content = {
                            {
                                'symlink_target',
                                highlight = 'NeoTreeSymbolicLinkTarget',
                                zindex = 10
                            },
                            {
                                'file_size',
                                zindex = 30
                            },
                            {
                                'last_modified',
                                zindex = 20
                            },
                            {
                                'created',
                                zindex = 10
                            },
                        }
                    }
                },
                directory = {
                    { 'indent' },
                    { 'icon' },
                    { 'current_filter' },
                    { 'git_status',    hide_when_expanded = true },
                    { 'name' },
                    { 'diagnostics',   errors_only = false,      hide_when_expanded = true },
                    { 'clipboard' },
                    {
                        'container',
                        content = {
                            {
                                'symlink_target',
                                highlight = 'NeoTreeSymbolicLinkTarget',
                                zindex = 10
                            },
                            {
                                'file_size',
                                zindex = 30
                            },
                            {
                                'last_modified',
                                zindex = 20
                            },
                            {
                                'created',
                                zindex = 10
                            },
                        },
                    }
                },
            }
  },
}

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

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@Kaiser-Yang Kaiser-Yang added the bug Something isn't working label Dec 31, 2024
@pynappo
Copy link
Collaborator

pynappo commented Dec 31, 2024

re: non-ascii, can you try #1623 ?

@Kaiser-Yang
Copy link
Author

re: non-ascii, can you try #1623 ?

It does not work:

image

@Kaiser-Yang
Copy link
Author

Kaiser-Yang commented Dec 31, 2024

BTW, I want to know how to make the container behave like this below (make size to the left when the window is wide, rather leaving large blank between them):

image

@pynappo
Copy link
Collaborator

pynappo commented Dec 31, 2024

BTW, I want to know how to make the container behave like this below (make size to the left when the window is wide, rather leaving large blank between them):

Try setting the alignment of the components. Relevant default config:

{ "file_size", zindex = 10, align = "right" },

@Kaiser-Yang
Copy link
Author

BTW, I want to know how to make the container behave like this below (make size to the left when the window is wide, rather leaving large blank between them):

Try setting the alignment of the components. Relevant default config:

{ "file_size", zindex = 10, align = "right" },

Yeah, I've tried that, but I don't know which one I should set, I find it only can be 'left' or 'right', but when I set it to 'left':

image

I've tried other combinations, like:

image

Or update container directly:

image

@pynappo pynappo closed this as completed Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants