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

Delay when opening Yazi with vim-projectionist #638

Closed
juanibiapina opened this issue Dec 28, 2024 · 3 comments
Closed

Delay when opening Yazi with vim-projectionist #638

juanibiapina opened this issue Dec 28, 2024 · 3 comments

Comments

@juanibiapina
Copy link

juanibiapina commented Dec 28, 2024

First of all thanks for the support ❤️

There's a delay when running :Yazi with vim-projectionist and the following config (note the * glob pattern):

vim.g.projectionist_heuristics = { ["*"] = {} }

Minimal reproducible example based on repro.lua. I marked the two ADDED lines.

repro.lua:

-- You can use this file to reproduce an issue with your configuration.

---@module "yazi"
---@module "lazy"

-- 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)
vim.g.mapleader = " "

-- install the following plugins
---@type LazySpec
local plugins = {
  { "catppuccin/nvim", name = "catppuccin", opts = { flavour = "macchiato" } },
  { "tpope/vim-projectionist" }, -- ADDED
  {
    "mikavilpas/yazi.nvim",
    event = "VeryLazy",
    keys = {
      {
        "<leader>-",
        "<cmd>Yazi<cr>",
        desc = "Open yazi at the current file",
      },
      {
        -- Open in the current working directory
        "<leader>cw",
        "<cmd>Yazi cwd<cr>",
        desc = "Open the file manager in nvim's working directory",
      },
      {
        -- NOTE: this requires a version of yazi that includes
        -- https://github.com/sxyazi/yazi/pull/1305 from 2024-07-18
        "<c-up>",
        "<cmd>Yazi toggle<cr>",
        desc = "Resume the last yazi session",
      },
    },
    ---@type YaziConfig
    opts = {
      open_for_directories = false,
      log_level = vim.log.levels.DEBUG,
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
  install = { colorscheme = { "catppuccin" } },
})

vim.g.projectionist_heuristics = { ["*"] = {} } -- ADDED

vim.cmd.colorscheme("catppuccin")
-- add anything else here

Extracted from #603

juanibiapina added a commit to juanibiapina/dotfiles that referenced this issue Dec 28, 2024
@mikavilpas
Copy link
Owner

Thanks a lot for the reproduction! It was very helpful, and I was able to reproduce the issue.

It looks like that plugin hijacks a huge number of internal calls. I didn't figure out what exactly causes the slowdown, but I found some workarounds that resolve it:

  1. https://github.com/tpope/vim-projectionist/blob/5ff7bf79a6ef741036d2038a226bcb5f8b1cd296/plugin/projectionist.vim?plain=1#L34-L35 allows setting vim.g.projectionist_ignore_term = true somewhere in your config. This resolved the slowdown for me. I think it disables lookups for terminal related calls.
  2. A more sophisticated mechanism seems to have been added here tpope/vim-projectionist@df1e28d. I think you could also add that function in your config and check if the buffer's filetype is "yazi" as in here
    vim.bo[yazi_buffer].filetype = "yazi"

@juanibiapina
Copy link
Author

Thanks for the support! This also solves it for me. Given how much stuff vim-projectionist is doing, I don't think it's an issue with yazi.vim.

@mikavilpas
Copy link
Owner

Closing this as it seems everything has been resolved 👍🏻

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

No branches or pull requests

2 participants