jvgrootveld / telescope-zoxide

An extension for telescope.nvim that allows you operate zoxide within Neovim.
MIT License
309 stars 17 forks source link

slow on windows #25

Closed konosubakonoakua closed 1 month ago

konosubakonoakua commented 1 month ago

it tooks about seconds to show up, sometimes even failed.

konosubakonoakua commented 1 month ago

BTW, my pwsh start up fast, because I use no profile

jvgrootveld commented 1 month ago

@konosubakonoakua Interesting. I notice no performance drops on my Mac. I don't have access to a Windows machine. Could you help me pinpoint possible issues?

Just to ask, are you sure this plugin is the issue? How did you test this and can you give me some reproducible steps?

konosubakonoakua commented 1 month ago

Yes, I'm sure we should add '-nop' to cmd list like this: pwsh -nop -c "zoxide query -ls" I also tried to add opts config but failed:

    -- Configure the extension
    opts = {
      extensions = {
        zoxide = {
          cmd = { "-nop", "-c", "zoxide query -ls"},
          prompt_title = "🙉 Zoxide",
          mappings = {
            default = {
              after_action = function(selection)
                print("Update to (" .. selection.z_score .. ") " .. selection.path)
              end,
            },
            ["<C-s>"] = {
              before_action = function(selection)
                print("before C-s")
              end,
              action = function(selection)
                -- vim.cmd.edit(selection.path)
                require("neo-tree.command").execute({ toggle = false, dir = vim.loop.cwd() })
              end,
            },
            -- ["<C-q>"] = { action = z_utils.create_basic_command("split") },
          },
        },
      },
    }
konosubakonoakua commented 1 month ago

the plugin didn't get the cmd I assigned.

konosubakonoakua commented 1 month ago

https://github.com/nvim-lua/plenary.nvim/blob/a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683/lua/plenary/test_harness.lua#L207

here, opts is always empty https://github.com/jvgrootveld/telescope-zoxide/blob/6d23b6135eb01e0540ab46c838fd44351876917a/lua/telescope/_extensions/zoxide/list.lua#L103

konosubakonoakua commented 1 month ago

or we modify the plugin src code:

  local shell_arg = { vim.o.shell }

  if vim.o.shell == "cmd.exe" then
    shell_arg[2] = "/c"
    shell_arg[3] = cmd
  elseif vim.o.shell == "pwsh" then
    shell_arg[2] = "-nop"
    shell_arg[3] = "-c"
    shell_arg[4] = cmd
  else
    shell_arg[2] = "-c"
    shell_arg[3] = cmd
  end
  opts.cmd = vim.F.if_nil(opts.cmd, shell_arg)
konosubakonoakua commented 1 month ago

Solved by:

vim.keymap.set("n", "<leader>sz",
  function()
    t.extensions.zoxide.list({ cmd = { "pwsh", "-nop", "-c", "zoxide query -ls" } })
  end, { desc = "zoxide" }
)
jvgrootveld commented 1 month ago

I'm glad you found a solution! I don't think pwsh (Powershell) would work on Mac and Linux though 😄