willothy / flatten.nvim

Open files and command output from wezterm, kitty, and neovim terminals in your current neovim instance
https://luarocks.org/modules/willothy/flatten.nvim
MIT License
466 stars 13 forks source link

Doesn't work with oil.nvim #100

Open XeroOl opened 1 month ago

XeroOl commented 1 month ago

I'm trying to use the plugins flatten.nvim and oil.nvim together, but oil buffers don't get transferred to the host properly.

The problem is that oil buffers have a filename like "oil:///home/xerool/Documents", which flatten.nvim fails to realize is absolute:

-- flatten/core.lua:148
is_absolute = string.find(fname, "^/") ~= nil

Note how oil:///home/xerool/Documents does not start with a / character and fails to match the ^/ pattern, but should probably still be treated as absolute because it has a schema provided.

To Reproduce

Steps to reproduce the behavior: 1) Open nvim with flatten.nvim and oil.nvim installed. 2) Run :terminal to get to a terminal. 3) In the terminal, run nvim Documents, or any other folder name. 4) Notice that you can't see the contents of the Documents folder on the screen, like you normally can in oil.nvim 5) Notice that :lua =vim.fn.expand("%") prints that the filename is /home/xerool/oil:///home/xerool/Documents instead of oil:///home/xerool/Documents

Expected behavior The filename oil:///home/xerool/Documents should be treated as absolute, and not modified.

Minimal Init

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end
vim.opt.rtp:prepend(lazypath)

-- install plugins
require("lazy").setup {
    "willothy/flatten.nvim",
    "stevearc/oil.nvim",
}

Desktop:

willothy commented 1 month ago

Thanks for reporting! I'm super busy with work atm but will try to get to this ASAP :)