You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I :setf rust in a new buffer without name (e.g., created by :new), rust-analyzer panics with error msg like this:
thread 'LspServer' panicked at crates/paths/src/lib.rs:79:36:
expected absolute path, got
The reason is that rust-analyzer expects usual file path, but rustaceanvim unconditionally attempts to attach any rust buffer even if its name is not an actual file path. This also happens for other kind of buffers with rust filetype, such as vim-fugitive's blob buffer, which has a name of form fugitive:///path/to/file.rs.
To avoid this, I ended up adding something like this in my config:
auto_attach=function()
-- Only attach to buf with actual file. rust-analyzer expects real path and panics otherwise.localb=vim.api.nvim_get_current_buf()
localpath=vim.fs.normalize(vim.api.nvim_buf_get_name(b), { expand_env=false })
returnvim.bo[b].buftype=='' andpath:sub(1,1) =='/'end,
While this worked for me, I believe this should be handled in rustaceanvim itself.
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion. It sounds reasonable off the top of my head.
I will have to make sure this also works for Windows, which can have paths that start with drive letters.
Feature description
When I
:setf rust
in a new buffer without name (e.g., created by:new
), rust-analyzer panics with error msg like this:The reason is that rust-analyzer expects usual file path, but rustaceanvim unconditionally attempts to attach any rust buffer even if its name is not an actual file path. This also happens for other kind of buffers with rust filetype, such as vim-fugitive's blob buffer, which has a name of form
fugitive:///path/to/file.rs
.To avoid this, I ended up adding something like this in my config:
While this worked for me, I believe this should be handled in rustaceanvim itself.
The text was updated successfully, but these errors were encountered: