mrcjkb / rustaceanvim

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

Error on loading rust file for the first time #422

Closed RhythmDeolus closed 1 month ago

RhythmDeolus commented 1 month ago

Have you read the docs and searched existing issues?

Neovim version (nvim -v)

v0.10.0

Operating system/version

WSL 2.0 on Windows 11

Output of :checkhealth rustaceanvim

rustaceanvim: require("rustaceanvim.health").check()

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.3.1916-standalone
- OK Cargo: found cargo 1.78.0 (54d8815d0 2024-03-26)
- OK rustc: found rustc 1.78.0 (9b00956e5 2024-04-29)
- 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

mkdir -p /tmp/minimal/
NVIM_DATA_MINIMAL="/tmp/minimal" NVIM_APP_NAME="nvim-minimal" nvim -u NORC -u minimal.lua
:e foo.rs

Expected behaviour

The rust file foo.rs should open and rust lsp should be attached to it

Actual behaviour

It gives me this following error before l am able to edit the file The rust lsp is working fine after I close the error but it always prompts me this error when I'm opening the rust file for the first time

image

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:356: bufnr: expected number, got table
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        /usr/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:356: in function 'is_enabled'
        .../minimal/rustaceanvim/lua/rustaceanvim/server_status.lua:21: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:1000: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

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 NORC -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',
    'https://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,
    lazy = false,
  },
  -- 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 1 month ago

Duplicate of https://github.com/mrcjkb/rustaceanvim/discussions/396