stevearc / oil.nvim

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

bug: cannot perform file/directory operations within LSP workspaces #410

Closed namvnngu closed 3 weeks ago

namvnngu commented 3 weeks ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

v0.10.0

Operating system/version

MacOS 14.5

Describe the bug

After updating oil.nvim to the commit, I cannot perform file/directory operations within LSP workspaces.

Error shown:

E5108: Error executing lua: ...local/share/nvim/lazy/oil.nvim/lua/oil/lsp/workspace.lua:80: attempt to call field 'has' (a nil value)
stack traceback:
        ...local/share/nvim/lazy/oil.nvim/lua/oil/lsp/workspace.lua:80: in function 'get_matching_paths'
        ...local/share/nvim/lazy/oil.nvim/lua/oil/lsp/workspace.lua:273: in function 'will_rename_files'
        .../.local/share/nvim/lazy/oil.nvim/lua/oil/lsp/helpers.lua:84: in function 'will_perform_file_operations'
        ....local/share/nvim/lazy/oil.nvim/lua/oil/mutator/init.lua:393: in function 'process_actions'
        ....local/share/nvim/lazy/oil.nvim/lua/oil/mutator/init.lua:567: in function 'cb'
        ...cal/share/nvim/lazy/oil.nvim/lua/oil/mutator/preview.lua:130: in function 'confirm'
        ...cal/share/nvim/lazy/oil.nvim/lua/oil/mutator/preview.lua:182: in function <...cal/share/nvim/lazy/oil.nvim/lua/oil/mutator/preview.lua:181>

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. Open any workspace that has LSP triggered.
  2. Open a random file to trigger LSP
  3. Try to delete a file

https://github.com/stevearc/oil.nvim/assets/42376176/bde077a0-17ee-4f99-8d1b-c5ca150716b4

Expected Behavior

I should be able to perform file/directory operations within LSP workspaces.

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?

namvnngu commented 3 weeks ago

This issue was fixed in the PR #411