Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP: error when renaming a rust module if a directory with the same name already exists #22147

Closed
Trard opened this issue Feb 6, 2023 · 0 comments · Fixed by #22289
Closed
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md lsp
Milestone

Comments

@Trard
Copy link
Contributor

Trard commented Feb 6, 2023

Neovim version (nvim -v)

NVIM v0.9.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g  -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fno-common -fdiagnostics-color=auto -fstack-protector-strong -DNVIM_UNIBI_HAS_VAR_FROM -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DMIN_LOG_LEVEL=3 -I/usr/include/luajit-2.1 -I/usr/include -I/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f/.deps/usr/include -I/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f/build/src/nvim/auto -I/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f/build/include -I/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f/build/cmake.config -I/build/neovim-EHMqJ7/neovim-0.9.0~ubuntu1+git202301150018-f445096cc-333b5866f/src Compiled by buildd@lcy02-amd64-066

Language server name/version

rust-analyzer 0.3.1229-standalone

Operating system/version

Ubuntu 20.04 (WSL Windows 10)

Steps to reproduce using "nvim -u minimal_init.lua"

  • Create a minimal_init.lua which setups rust_analyzer lsp
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  "neovim/nvim-lspconfig"
})

vim.keymap.set("n", "rn", vim.lsp.buf.rename, { noremap = true })
require'lspconfig'.rust_analyzer.setup{}
  • Go to any rust project with 2+ nesting level.
git clone https://github.com/Trard/rust-neovim-314.git && cd rust-neovim-314
  • Open a file which contains module with 2+ nesting level.
nvim -u path/to/minimal.lua src/main.rs
  • Try to rename this module using vim.lsp.buf.rename

demo

Expected behavior

All files (including directory) have successfully renamed.

Actual behavior

The directory with the same name as the module haven't renamed. An error have occurred:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:762: Error executing lua: /usr/s
hare/nvim/runtime/lua/vim/lsp/util.lua:763: Vim(write):E502: "src/bar" is a directory
stack traceback:
        [C]: in function 'cmd'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:763: in function </usr/share/nvim/runtime/lua/vim/lsp/util.lua:762>

        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:762: in function 'rename'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:828: in function 'apply_workspace_edit'
        /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:279: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/buf.lua:314: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1391: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
stack traceback:
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:762: in function 'rename'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:828: in function 'apply_workspace_edit'
        /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:279: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/buf.lua:314: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1391: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Log file

https://gist.github.com/Trard/d8065979730e7b9693235e6af057e576

@Trard Trard added bug issues reporting wrong behavior lsp labels Feb 6, 2023
@Trard Trard changed the title renaming a module causes an error if a directory with the same name as the module exists Renaming a rust module causes an error if a directory with the same name as the module exists Feb 6, 2023
@justinmk justinmk changed the title Renaming a rust module causes an error if a directory with the same name as the module exists LSP: error when renaming a rust module if a directory with the same name already exists Feb 15, 2023
@justinmk justinmk added this to the backlog milestone Feb 15, 2023
@justinmk justinmk added good-first-issue complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md labels Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md lsp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants