mrcjkb / rustaceanvim

🦀 Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim
GNU General Public License v2.0
1.81k stars 68 forks source link

Error when opening rust file on Neovim 0.10 #266

Closed Shock9616 closed 9 months ago

Shock9616 commented 9 months ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-2480+g0eaae1bc0

Operating system/version

macOS Sonoma 14.3.1

Output of :checkhealth rustaceanvim

Minimal config:

Checking for Lua dependencies
- WARNING dap not installed. Needed for debugging features [mfussenegger/nvim-dap](https://   github.com/mfussenegger/nvim-dap)

Checking external dependencies
- OK rust-analyzer: found rust-analyzer 0.0.0 (5346002d0 2024-02-25)
- OK Cargo: found cargo 1.74.1 (ecb9851af 2023-10-18)
- OK rustc: found rustc 1.74.1 (a28077b28 2023-12-04)

Checking config
- OK No errors found in config.

Checking for conflicting plugins
- OK No conflicting plugins detected.

Checking for tree-sitter parser
- WARNING No tree-sitter parser for Rust detected. Required by 'Rustc unpretty' command.

My full config:

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 0.0.0 (5346002d0 2024-02-25)
- OK Cargo: found cargo 1.74.1 (ecb9851af 2023-10-18)
- OK rustc: found rustc 1.74.1 (a28077b28 2023-12-04)
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected.

How to reproduce the issue

cd <some/cargo/project/root>
mkdir -p /tmp/minimal
NVIM_DATA_MINIMAL="/tmp/minimal" NVIM_APP_NAME="nvim-minimal" nvim -u minimal.lua
:e src/main.rs

Expected behaviour

The file should open with no errors.

Actual behaviour

On opening a rust file in a cargo project, this error occurs and all rust_analyzer features are missing.

Error executing luv callback:
/usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:606: E5560: nvim_err_writeln must not be called in a lua loop callback
stack traceback:
        [C]: in function 'nvim_err_writeln'
        /usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:606: in function 'err_message'
        /usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:853: in function 'write_error'
        /usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:432: in function '_run_callbacks'
        /usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:931: in function 'on_exit'
        /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:811: in function 'on_exit'
        /usr/local/share/nvim/runtime/lua/vim/_system.lua:297: in function </usr/local/share/nvim/runtime/lua/vim/_system.lua:267>
        [C]: in function 'nvim_exec_autocmds'
        /tmp/minimal/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:157: in function </tmp/minimal/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:156>
        [C]: in function 'xpcall'
        /tmp/minimal/lazy/lazy.nvim/lua/lazy/core/util.lua:113: in function 'try'
        /tmp/minimal/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:156: in function 'trigger'
        /tmp/minimal/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:87: in function </tmp/minimal/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:72>
        [C]: in function 'nvim_cmd'
        /usr/local/share/nvim/runtime/filetype.lua:31: in function </usr/local/share/nvim/runtime/filetype.lua:30>
        [C]: in function 'nvim_buf_call'
        /usr/local/share/nvim/runtime/filetype.lua:30: in function </usr/local/share/nvim/runtime/filetype.lua:10>

Neovim 0.9.x works just fine.

The minimal config used to reproduce this issue.

-- Minimal nvim config with lazy
-- Assumes a directory in $NVIM_DATA_MINIMAL
-- Start with
--
-- export NVIM_DATA_MINIMAL=$(mktemp -d)
-- export NVIM_APP_NAME="nvim-ht-minimal"
-- nvim -u minimal.lua
--
-- Then exit out of neovim and start again.

-- Ignore default config
local config_path = vim.fn.stdpath("config")
vim.opt.rtp:remove(config_path)

-- Ignore default plugins
local data_path = vim.fn.stdpath("data")
local pack_path = data_path .. "/site"
vim.opt.packpath:remove(pack_path)

-- bootstrap lazy.nvim
data_path = assert(os.getenv("NVIM_DATA_MINIMAL"), "$NVIM_DATA_MINIMAL environment variable not set!")
local lazypath = data_path .. "/lazy/lazy.nvim"
local uv = vim.uv
    ---@diagnostic disable-next-line: deprecated
    or vim.loop
if not uv.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "git@github.com:folke/lazy.nvim.git",
        "--branch=stable",
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

local lazy = require("lazy")

lazy.setup({
    {
        "mrcjkb/rustaceanvim",
        version = "^4",
        init = function()
            -- Configure rustaceanvim here
            vim.g.rustaceanvim = {}
        end,
        ft = { "rust" },
    },
    -- Add any other plugins needed to reproduce the issue.
    -- see https://github.com/folke/lazy.nvim#-lazynvim for details.
}, { root = data_path, state = data_path .. "/lazy-state.json", lockfile = data_path .. "/lazy-lock.json" })
mrcjkb commented 9 months ago

Duplicate of https://github.com/mrcjkb/rustaceanvim/issues/248 😃