Closed xzbdmw closed 3 months ago
Hey 👋
Thanks for reporting. The config you posted contains a lot that is irrelevant for reproducing the behaviour. Could you please try to reproduce this starting from the minimal config provided in the readme's troubleshooting section (without any other plugins or settings), adding plugins and settings gradually until you can reproduce it? 🙏
The config just contains the project manage plugin(it depends on neovim-session-manager and telescope) and rustaceanvim, you can ignore those option settings( I copy paste it ), neovim-projet.nvim is a wrapper around neovim-session-manager and telescope is just used for change project. these are four basic plugins to reproduce it.
you can try
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({
{ "nvim-lua/plenary.nvim" },
{
"coffebar/neovim-project",
-- enabled = false,
opts = {
last_session_on_startup = true,
projects = { -- define project roots
"~/Project/rust/*",
"~/Project/Go/*",
"~/.config/*",
},
session_manager_opts = {
sessions_dir = "/Users/xzb/.local/share/nvimtest/sessiontest", -- The directory where the session files will be saved.
session_filename_to_dir = session_filename_to_dir, -- Function that replaces symbols into separators and colons to transform filename into a session directory.
dir_to_session_filename = dir_to_session_filename, -- Function that replaces separators and colons into special symbols to transform session directory into a filename. Should use `vim.loop.cwd()` if the passed `dir` is `nil`.
-- autoload_mode = config.AutoloadMode.LastSession, -- Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession
autosave_last_session = true, -- Automatically save last session on exit and on session switch.
autosave_ignore_not_normal = true, -- Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed.
autosave_ignore_dirs = {}, -- A list of directories where the session will not be autosaved.
autosave_ignore_filetypes = { -- All buffers of these file types will be closed before the session is saved.
"gitcommit",
"gitrebase",
},
autosave_ignore_buftypes = {}, -- All buffers of these bufer types will be closed before the session is saved.
autosave_only_in_session = false, -- Always autosaves session. If true, only autosaves after a session is active.
max_path_length = 80, -- Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all.
},
},
init = function()
-- enable saving the state of plugins in the session
vim.opt.sessionoptions:append("globals") -- save global variables that start with an uppercase letter and contain at least one lowercase letter.
end,
dependencies = {
{ "Shatur/neovim-session-manager" },
{ "nvim-telescope/telescope.nvim" },
{ "nvim-lua/plenary.nvim" },
},
lazy = false,
priority = 100,
},
{ "nvim-lua/plenary.nvim" },
{
"mrcjkb/rustaceanvim",
-- version = "^3", -- Recommended
ft = { "rust" },
},
})
The config just contains the project manage plugin(it depends on neovim-session-manager and telescope) and rustaceanvim, you can ignore those option settings( I copy paste it ), neovim-projet.nvim is a wrapper around neovim-session-manager and telescope is just used for change project. these are four basic plugins to reproduce it.
I know what each of the plugins do. Let me clarify:
I maintain this plugin in my free time, and do not have the capacity to account for non-standard behaviour that other plugins might be adding to neovim - especially if I don't use those plugins myself (there are a lot of neovim plugins out there and I have a lot of people asking for help with various problems, often related to other plugins).
That's why I provide a minimal config and instructions to try to reproduce the behaviour. First without any other plugins, and then to add plugins you suspect could be causing the behaviour one by one, so that you can identify which plugin (or which configuration) is the cause.
If you suspect this behaviour is caused by neovim-project, and neovim-project is a wrapper around neovim-session-manager, the steps to identify the culprit could be as follows:
:e ../path/to/other/project/file.rs
opts
and without Telescope). Can the behaviour be reproduced?opts
(one by one, not all at once).Furthermore, in your specific case, you provided this:
projects = { -- define project roots
"~/Project/rust/*",
"~/Project/Go/*",
"~/.config/*",
},
I do not have a "Project/rust" or "Project/go" in my home directory. And I don't know which kinds of projects you have in those directories. To be able to understand how to reproduce this on my device, I would have to read through the neovim-project and neovim-session-manager plugins' documentations, and also make (possibly wrong) assumptions about your projects. That's why I ask for precise steps to reproduce.
For example:
mkdir -p /tmp/rust
cd /tmp/rust
cargo new foo
cargo new bar
cd foo
nvim
... etc
Once you have a minimal reproducible config, I am more than happy to invest time in finding a fix or helping to identify a bug in another plugin. But I do not have the capacity to determine which plugin is making rustaceanvim behave this way for you.
I can't reproduce it using neovim-session-manager alone. and this commit https://github.com/mrcjkb/rustaceanvim/commit/5fb048d9a59872547f9ed94b964cf4b35ed6c2fc breaks neovim-project
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({
{
"coffebar/neovim-project",
-- enabled = false,
opts = {
last_session_on_startup = true,
projects = { -- define project roots
"~/testsession/*",
},
},
init = function()
-- enable saving the state of plugins in the session
vim.opt.sessionoptions:append("globals") -- save global variables that start with an uppercase letter and contain at least one lowercase letter.
end,
dependencies = {
{ "Shatur/neovim-session-manager" },
{ "nvim-telescope/telescope.nvim" },
{ "nvim-lua/plenary.nvim" },
},
lazy = false,
priority = 100,
},
{ "nvim-lua/plenary.nvim" },
{
"mrcjkb/rustaceanvim",
-- version = "^3", -- Recommended
ft = { "rust" },
},
})
the detail reproduce steps:
:Telescope neovim-project discover
select foo and open a rust file(:Telescope find_files
select main.rs) see lsp works:Telescope neovim-project history
to switch to another project(foo)Thanks :pray:
I wasn't able to reproduce the issue with the config and steps you posted.
:lua =#vim.lsp.buf_get_clients()
outputs 1
, showing that there is only one client attached.
Did you run Neovim as described in the README, to ensure there are no other configs or plugins polluting the environment?
mkdir -p /tmp/minimal/
NVIM_DATA_MINIMAL="/tmp/minimal" NVIM_APP_NAME="nvim-minimal" nvim -u NORC -u minimal.lua
This commit in neovim-project looks suspicious to me: https://github.com/coffebar/neovim-project/commit/68a31ba10d1071906ebc942838f008db800431c9
But it doesn't seem to be causing any problems on my end.
Commit https://github.com/mrcjkb/rustaceanvim/commit/5fb048d9a59872547f9ed94b964cf4b35ed6c2fc is a bug fix, and is the intended behaviour.
vim.lsp.start
won't attach a second LSP client if there is already one attached with the same workspace root.
That's strange, I use the init.lua provided above
this is my version
rust-analyzer --version
rust-analyzer 1.76.0 (07dca489 2024-02-04)
That's strange, I use the init.lua provided above
iShot_2024-03-08_01.26.47.mp4 this is my version
rust-analyzer --version rust-analyzer 1.76.0 (07dca489 2024-02-04)
It looks like you're not using NVIM_DATA_MINIMAL
or -u NORC -u minimal.lua
(see the snippet in my previous comment). These are important to make sure you launch Neovim with a clean, repeatable environment that isn't polluted with configs that could be getting loaded without your knowledge.
I will try
Hello I can reproduce this using https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua, not sure what cause the difference😰
Hello I can reproduce this using https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua, not sure what cause the difference😰
Wait, you can reproduce it without any other plugins now?
:thinking: maybe it's a neovim-nightly bug or a MacOS thing? Can you reproduce it with Neovim 0.9?
0.9.5 have the same problem😇, luckily I can live before that commit.
0.9.5 have the same problem😇, luckily I can live before that commit.
What are the steps to reproduce it without neovim-project? Perhaps I can try to reason about it and if not I'll add some logging that might help (I wanted to do that anyway) 😃
By the way, you could probably work around it with the vim.g.rustaceanvim.server.auto_attach
option (see :h rustaceanvim.config
) if I don't find a fix soon.
Thanks 🙏
I wasn't able to reproduce the issue with the config and steps you posted.
:lua =#vim.lsp.buf_get_clients()
outputs1
, showing that there is only one client attached.Did you run Neovim as described in the README, to ensure there are no other configs or plugins polluting the environment?
mkdir -p /tmp/minimal/ NVIM_DATA_MINIMAL="/tmp/minimal" NVIM_APP_NAME="nvim-minimal" nvim -u NORC -u minimal.lua
This commit in neovim-project looks suspicious to me: coffebar/neovim-project@68a31ba
But it doesn't seem to be causing any problems on my end.
Commit 5fb048d is a bug fix, and is the intended behaviour.
vim.lsp.start
won't attach a second LSP client if there is already one attached with the same workspace root.
yes before this commit in neovim-project there is no problem. So it is their issue though.
Let's leave this issue open though. I think it's too early to rule out a bug in rustaceanvim.
Because I can't reproduce using neovim-sessino-manager alone
Neovim version (nvim -v)
0.10
Operating system/version
macos 14.2
Output of :checkhealth rustaceanvim
How to reproduce the issue
init.lua
reproduce:
:Telescope neovim-project discover
select one rust project:Telescope neovim-project history
to switch to another projectExpected behaviour
one ra per project
Actual behaviour
two ra
The minimal config used to reproduce this issue.