ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.84k stars 455 forks source link

`Lspsaga diagnose_jump_next` error with `'replacement string' item contains newlines` in rust-analyzer lsp #1064

Closed csyJoy closed 8 months ago

csyJoy commented 8 months ago

Version confirmation

Following prerequisites

Not a user config issue

Neovim version

NVIM v0.9.4

Operating system/version

macOS 14.0

Terminal name/version

alacritty 0.12.3 (5efb069)

$TERM environment variable

No response

Branch info

main (Default/Latest)

Fetch Preferences

SSH (use_ssh = true)

Affected language servers

rust-analyzer

How to reproduce the issue

  1. cargo new foo

  2. nvim foo/src/main.rs

  3. replace with the following code

    fn main() {
    let mut bt: BTreeMap<i32, i32> = BTreeMap::new();
    }
  4. save the file and current buffer will be like this:

    image
  5. use :Lspsaga diagnostic_jump_prev in line 2 and you will get an error:

    image

    and the error window spawned remain blank:

    image

Actual behavior

Error executing Lua callback: ...share/nvim/site/lazy/lspsaga.nvim/lua/lspsaga/window.lua:118: 'replacement string' item contains newlines
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...share/nvim/site/lazy/lspsaga.nvim/lua/lspsaga/window.lua:118: in function 'setlines'
        ...m/site/lazy/lspsaga.nvim/lua/lspsaga/diagnostic/init.lua:313: in function 'render_diagnostic_window'
        ...m/site/lazy/lspsaga.nvim/lua/lspsaga/diagnostic/init.lua:423: in function 'move_cursor'
        ...m/site/lazy/lspsaga.nvim/lua/lspsaga/diagnostic/init.lua:437: in function 'goto_next'
        ...hare/nvim/site/lazy/lspsaga.nvim/lua/lspsaga/command.lua:41: in function <...hare/nvim/site/lazy/lspsaga.nvim/lua/lspsaga/command.lua:40>
        ...hare/nvim/site/lazy/lspsaga.nvim/lua/lspsaga/command.lua:74: in function 'load_command'
        ...cal/share/nvim/site/lazy/lspsaga.nvim/plugin/lspsaga.lua:8: in function <...cal/share/nvim/site/lazy/lspsaga.nvim/plugin/lspsaga.lua:7>

Expected behavior

Lspsaga spawn error window within error message and code action correctly

Support info

Lspinfo:

image

:Mason

image

Logs

No response

Additional information

I add vim.print() in setlines function in Lspsaga:

function obj:setlines(lines, row, erow)
  row = row or 0
  erow = erow or -1
  vim.print(lines)
  api.nvim_buf_set_lines(self.bufnr, row, erow, false, lines)
  return self
end

here is the result of the line information:

{ "cannot find type `BTreeMap` in this scope", "not found in this scope", "main.rs(1:0): consider importing this struct: `use std::collections::BTreeMap;\n\n`" }

PS: this time I've taken a look at existing issues including this repository as well as lspsaga.nvim but find nothing similar. Forgive me if there's something I've missed that I haven't picked up on, I didn't mean to do it : )

vollowx commented 8 months ago

consider reporting to lspsaga?

csyJoy commented 8 months ago

after reporting, lspsage fix this issue https://github.com/nvimdev/lspsaga.nvim/commit/87786212c30e36d37478f8a6c30c1d9a98db4751