stevearc / oil.nvim

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

bug: LSP willRenameFiles not work #247

Closed lightseazz closed 9 months ago

lightseazz commented 10 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.4/ Build type: Release/ LuaJIT 2.1.1700008891

Operating system/version

Arch Linux x86_64 Kernel: 6.1.63-1-lts

Describe the bug

I use Mason to install tsserver and use lspconfig to setup tsserver (you can see in repro.lua below).

I know since version 2.3.0 you have implemented LSP willRenameFiles to auto change import name if i rename file, but it doesn't work. if I use nvim-lsp-file-operations + nvim-tree, it works.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. Create test folder like this image file foo.js image file test.js image file jsconfig.js image

  2. nvim -u repro.lua test/ , Install typescript-language-server using Mason.

  3. use command :LspInfo check if client is attached. image

  4. change foo.js to bar.js and save. In test.js , import still foo image image

Expected Behavior

if I change file name, import will also change.

Directory structure

test/foo.js test/test.js test/jsconfig.js

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,
  },
    -- lsp
    "williamboman/mason.nvim",
    "williamboman/mason-lspconfig.nvim",
    {
        "neovim/nvim-lspconfig",
    },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

require("mason").setup()
require("mason-lspconfig").setup {
    ensure_installed = { "tsserver" },
}

local lspconfig = require("lspconfig")
lspconfig.tsserver.setup {}

Did you check the bug with a clean config?

lightseazz commented 10 months ago

By the way, it seems commit #636989b make preview in the left screen, it's nice if you can make it back to rightscreen by default.

mortezadadgar commented 10 months ago

By the way, it seems commit #636989b make preview in the left screen, it's nice if you can make it back to rightscreen by default.

that commit made changes to respect splitright option

lightseazz commented 10 months ago

By the way, it seems commit #636989b make preview in the left screen, it's nice if you can make it back to rightscreen by default.

that commit made changes to respect splitright option

yes I know. I mean it's nicer if preview is on right screen by default :smiley: