mikavilpas / yazi.nvim

A Neovim Plugin for the yazi terminal file manager
MIT License
459 stars 16 forks source link

An unknown element "" was received #366

Closed Daydreamer-riri closed 1 month ago

Daydreamer-riri commented 1 month ago

Thank you for your great work! I encountered some issues while trying to use it. It does not work properly on Windows.

yazi ~
- Running yazi.nvim version 5.5.0
- WARNING yazi --version looks unexpected, saw An unknown element "" was received. This can happen if the remote process closed or ended abnormally.

- ERROR Failed to run healthcheck for "yazi" plugin. Exception:
  ...gram Files/Neovim/share/nvim/runtime/lua/vim/version.lua:174: attempt to index local 'version' (a nil value)

image

image

mikavilpas commented 1 month ago

Hello! I don't use windows myself unfortunately, but it looks like the healthcheck fails to run because the following command fails:

:=vim.fn.system("yazi --version")

I bet to fix the issue, that command should succeed. It probably indicates something is wrong with your neovim setup on windows.

mikavilpas commented 1 month ago

The same error message seems to appear here, maybe something like this can help you https://github.com/neovim/neovim/issues/13893

Daydreamer-riri commented 1 month ago

‌‌Thank you very much for your prompt reply! Indeed, that's the reason. I simply set the shell without making the relevant settings. Thank you!

Daydreamer-riri commented 1 month ago

Hi @mikavilpas, sorry to bother you again. I tried to switch to using yazi.nvim in nushell and got this error:

image

Error: nu::shell::file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ nu
   · ▲
   · ╰── Could not access file '/s': 系统找不到指定的文件。 (os error 2)
   ╰────

[Process exited 1]
mikavilpas commented 1 month ago

Hmm, I have received reports from nushell users saying the plugin does work. Maybe you have to enable these for now (ref. https://github.com/mikavilpas/yazi.nvim/issues/130#issuecomment-2241063898)

    -- enable these if you are using the latest version of yazi
    -- use_ya_for_events_reading = true,
    -- use_yazi_client_id_flag = true,

See the readme for where you should put these: https://github.com/mikavilpas/yazi.nvim?tab=readme-ov-file#using-lazynvim

I will make these the default option in some time, but for now you need to enable them manually.

Daydreamer-riri commented 1 month ago

I have enabled it. You can see my configuration here: nushell: https://github.com/Daydreamer-riri/LazyVimConfig/blob/main/lua/config/options.lua#L6-L14 yazi: https://github.com/Daydreamer-riri/LazyVimConfig/blob/main/lua/plugins/yazi.lua#L32-L33

Perhaps there is an issue with calling nushell through the neovim API on Windows. When I execute:

:=vim.fn.system("")

I get the same error.

Daydreamer-riri commented 1 month ago

https://github.com/neovim/neovim/issues/19648#issuecomment-1212295560 When I made the changes according to the instructions here, I got a different error:

Error:   × Invalid literal
   ╭─[source:1:9]
 1 │ yazi "D:\Users\ding.zhao\workspace\rn_dingzhi" --local-events "rename,delete,trash,move,cd" --chooser-file "D:\Users\DING~1.ZHA\AppData\Local\Temp\nvim.0\M3x4bW\0" > "D:\Users\DING~1.
ZHA\AppData\Local\Temp\nvim.0\M3x4bW\1"
   ·         ───────────────────┬──────────────────
   ·                            ╰── unrecognized escape after '\' in string
   ╰────

[Process exited 1]
mikavilpas commented 1 month ago

Hmm to be honest I have no idea what could be wrong with your setup. I'm not familiar with how neovim works on windows at all.

Does the same command work for you without neovim? Maybe neovim thinks it should use \ characters as file separators since you are on windows, but they are not understood by nushell...

Daydreamer-riri commented 1 month ago

image It seems this is an issue upstream. The same command works normally in PowerShell. Thank you for your reply! Apologies for taking up your time.

Daydreamer-riri commented 3 weeks ago

Hi @mikavilpas, I dug into this again (since I use nushell more frequently and have to wait almost a second to open yazi.nvim in powershell, I wanted to try nushell), and I found out that the reason yazi.nvim is not available in nushell is this: https://github.com/ nushell/nushell/issues/8174, i.e. “backslash in double quotes” in “path\to\file” is treated as an escape character. Is there any way to fix this?

mikavilpas commented 3 weeks ago

Hmm I'm not sure what the problem could be. If I try to replicate the issue with e reproduction setup described here (on osx) using the following command, I have no trouble opening yazi and then opening a file.

SHELL=nu nvim -u repro.lua

Can you try and see if you have the same behaviour?

Daydreamer-riri commented 3 weeks ago

OSX work fine because it's dir separator is ’/’, but windows's dir separator is ’\’. So you can see that error from my previous reply.

https://github.com/neovim/neovim/issues/19648#issuecomment-1212295560 When I made the changes according to the instructions here, I got a different error:

Error:   × Invalid literal
   ╭─[source:1:9]
 1 │ yazi "D:\Users\ding.zhao\workspace\rn_dingzhi" --local-events "rename,delete,trash,move,cd" --chooser-file "D:\Users\DING~1.ZHA\AppData\Local\Temp\nvim.0\M3x4bW\0" > "D:\Users\DING~1.
ZHA\AppData\Local\Temp\nvim.0\M3x4bW\1"
   ·         ───────────────────┬──────────────────
   ·                            ╰── unrecognized escape after '\' in string
   ╰────

[Process exited 1]

The command executed by this plugin is a path wrapped through double quotes, and the separator of the path is a backslash, which is considered an escape character.

In addition, if the backslash is replaced with a forward slash, the command here can be executed normally. This may be because YAZI automatically handles the path separators of different systems.

Daydreamer-riri commented 3 weeks ago

I can't test it yet because my personal computer is arm windows and can't install nvim. Next week I will try to change YAZI.nvim locally on my work computer to see if it works properly.

mikavilpas commented 3 weeks ago

I suspect it might be related to neovim somehow. It might also be that in this plugin, the library plenary.nvim is used that might not support nushell like paths yet.

Daydreamer-riri commented 3 weeks ago

https://github.com/mikavilpas/yazi.nvim/blob/main/lua%2Fyazi%2Fprocess%2Fya_process.lua#L58-L58

I see this function: shellescape, according to the documentation I set shellslash to true, and then yazi.nvim can be opened normally in nushell. I'm not sure if there will be other questions, and I'll report it if there is.

Thank you for always following this issue!

mikavilpas commented 3 weeks ago

Wow that's really resourceful. Did not know such a setting exists, but glad it works!

Daydreamer-riri commented 2 weeks ago

Hi @mikavilpas, this setting I use breaks some other plugins. I ended up making this modification:

{6FF75C79-5B47-44F4-BE0E-9091EED24B0D}

Do you mind if I submit a PR for running yazi.nvim in windows nushell to have this behavior? Maybe as a configuration item, I'm not sure what form this should take.

If you don't think this is appropriate, I can keep it in my personal fork.

mikavilpas commented 2 weeks ago

Hmm I'm glad it worked for you. I suspect something is not right in Neovim itself possibly, as I have seen neo-tree also has pretty complicated logic for escaping paths.

Let's keep it on your form for now. I think this will never change, but if this starts to come up more I can maybe add a configuration option for it in the future.

Daydreamer-riri commented 2 weeks ago

Hmm I'm glad it worked for you. I suspect something is not right in Neovim itself possibly, as I have seen neo-tree also has pretty complicated logic for escaping paths.

Let's keep it on your form for now. I think this will never change, but if this starts to come up more I can maybe add a configuration option for it in the future.

Sure, thanks for your work!