stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.4k stars 92 forks source link

bug: extra slash in path on ssh connection #383

Closed slavamak closed 1 month ago

slavamak commented 1 month ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOS 14.4.1

Describe the bug

Hi there! Not sure if this is a problem but I noticed that there is an extra slash in the path. This slash is added when a connection to ssh is established. It's not a bug on my end but as a perfectionist I find it a bit annoying. Thanks :)

render1716115251027

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. nvim -u repro.lua
  2. :e oil-ssh://user@host/

Then we get connection to path like oil-ssh://user@host//root

Expected Behavior

The path must not contain an extra slash, for example oil-ssh://user@host/root or oil-ssh://user@host:/root, I guess

Directory structure

No response

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

Did you check the bug with a clean config?

stevearc commented 1 month ago

This is intentional and mirrors the format that netrw uses. Instead of scp://[<username>@]<hostname>[:<port>]/<path> we use oil-ssh://[<username>@]<hostname>[:<port>]/<path>. The key being that the / after the hostname/port is necessary so that we know when it has ended and the path is beginning. If the path on the remote machine is an absolute path, then it will start with a /. This is why the full url will have two slashes there.

slavamak commented 1 month ago

Got you, thanks for the explanation!