Skip to content

fix(picker): exclude full_name window id from the choice #3165

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

Conversation

przepompownia
Copy link
Contributor

Problem: full_name window from is considered as usable by picker
Solution: exclude its ID (also true for nil values)

Problem: `full_name` window from is considered as usable by picker
Solution: exclude its ID (also true for nil values)
@alex-courtis
Copy link
Member

Thanks for picking this one up. Unfortunately I'm not able to reproduce.

Attempted with:

{
  on_attach = M.on_attach,
  renderer = {
    full_name = true,
  },
  actions = {
    open_file = {
      window_picker = {
        enable = true,
        picker = "default",
        chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
        exclude = {
          -- filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
          -- buftype = { "nofile", "terminal", "help" },
          filetype = { "foo" },
          buftype = { "bar" },
        },
      },
    },
  },
}

Terminal and empty windows were available, but not full_name

20250715_102538

@przepompownia
Copy link
Contributor Author

przepompownia commented Jul 15, 2025

image

Please try with the only (except NvimTree) window. I can reproduce it with the below init file.

init.lua
local thisInitFile = debug.getinfo(1).source:match('@?(.*)')
local cwd = vim.fs.dirname(thisInitFile)
local appname = vim.env.NVIM_APPNAME or 'nvim'

vim.env.XDG_CONFIG_HOME = cwd
vim.env.XDG_DATA_HOME = vim.fs.joinpath(cwd, '.xdg', 'data')
vim.env.XDG_STATE_HOME = vim.fs.joinpath(cwd, '.xdg', 'state')
vim.env.XDG_CACHE_HOME = vim.fs.joinpath(cwd, '.xdg', 'cache')
vim.fn.mkdir(vim.fs.joinpath(vim.env.XDG_CACHE_HOME, appname), 'p')
local stdPathConfig = vim.fn.stdpath('config')

vim.opt.runtimepath:prepend(stdPathConfig)
vim.opt.packpath:prepend(stdPathConfig)

local function gitClone(url, installPath, branch)
  if vim.fn.isdirectory(installPath) ~= 0 then
    return
  end

  local command = {'git', 'clone', '--', url, installPath}
  if branch then
    table.insert(command, 3, '--branch')
    table.insert(command, 4, branch)
  end

  vim.notify(('Cloning %s dependency into %s...'):format(url, installPath), vim.log.levels.INFO, {})
  local sysObj = vim.system(command, {}):wait()
  if sysObj.code ~= 0 then
    error(sysObj.stderr)
  end
  vim.notify(sysObj.stdout)
  vim.notify(sysObj.stderr, vim.log.levels.WARN)
end

local pluginsPath = vim.fs.joinpath(cwd, 'nvim/pack/plugins/opt')
vim.fn.mkdir(pluginsPath, 'p')
pluginsPath = vim.uv.fs_realpath(pluginsPath)

--- @type table<string, {url:string, branch: string?}>
local plugins = {
  ['nvim-tree'] = {url = 'https://github.com/przepompownia/nvim-tree.lua'},
}

for name, repo in pairs(plugins) do
  local installPath = vim.fs.joinpath(pluginsPath, name)
  gitClone(repo.url, installPath, repo.branch)
  vim.opt.runtimepath:append(installPath)
  -- vim.cmd.packadd({args = {name}, bang = true})
end

vim.api.nvim_create_autocmd('UIEnter', {
  once = true,
  callback = function ()
    require('nvim-tree').setup({
      actions = {
        open_file = {
          window_picker = {
            exclude = {
              buftype = {'prompt'},
            },
          },
        },
      },
      renderer = {
        full_name = true,
      },
    })
    require('nvim-tree.api').tree.open()
  end,
})

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try with the only (except NvimTree) window. I can reproduce it with the below init file.

I can replicate, thank you.

Under the default configuration buftype = { "nofile" excludes the full-name window.

There are use cases for removing "nofile", however no use cases for opening in the full-name window.

This change works beautifully, many thanks for your contribution!

@alex-courtis
Copy link
Member

The CI failure is also on master. I'll fix it there, rebase this branch, then merge.

@alex-courtis alex-courtis merged commit 543ed3c into nvim-tree:master Jul 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants