Closed tomshoo closed 2 years ago
Look like your LSP workspace is changed. From the log, there are four clients for four rust-analyzer
, but ufo can't select an appropriate client in multiple clients.
FYI: nvimlsp will spawn a process if the workspace is different.
nvimlsp will spawn a process if the workspace is different.
That's weird. From what I know of about rust based projects is that Cargo.toml
belongs to the same workspace of the project. In fact it is what defines the root of the project. Which means that opening(as shown in the video) that one should not switch the workspace nor should it give the LSP a reason to create a new workspace.
Edit: I should rather go to rust-analyzer or neovim directly to enquire further about this behavior. I am traveling right now but will get to it first thing once I reach college.
You'd better use a template and provide the step to reproduce the issue.
Apologies for my late response, as I previously mentioned, I am traveling.
You'd better use a template and provide the step to reproduce the issue.
Alright I'll try to be as clear as possible. If my initial post was unsuccessful with explaining the issue, I'll try to explain my steps more thoroughly once more.
For the sake of this post let us assume a project structure as such,
root/
|-- Cargo.toml
|-- src/
|-- lib.rs
|-- module/
|-- mod.rs
|-- file1.rs
Following are the steps to reproduce the issue in such project,
:Telescope projects
lib.rs
file1.rs
from the project structure mentioned above. This does not cause any crash.Cargo.toml
from NvimTree and then I see the issue mentioned in the original post, i.e,
I am currently circumventing this by disabling ufo
when rust-analyzer
is attached, because only rust-analyzer has so far caused any trouble, all other LSP(s) tend to work nicely with the plugin.
I shall also report this to rust-analyzer
, by opening a new issue over there, because from what you have stated and what I have observed this issue is rather a side-effect of something funky going on behind the curtains.
From what I can observe the LSP treats opening root files as opening a new workspace.
I guess I should rather close this issue and open a new one in the proper place, but I will be waiting for your suggestion.
Thanks, but I guess you misunderstand the template.
cat mini.lua
-- Use Vim packages install the plugin, also work with some plugins manager such as packer.nvim
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd('packadd promise-async')
vim.cmd('packadd nvim-ufo')
-- Setting
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true
local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)
nvim --clean -u mini.lua
1. 2. 3. ...
If I can't reproduce it, I have no clue to solve it.
If you are busy now, use treesitter
provider instead.
local ftMap = {
rust = {'treesitter', 'indent'}
}
require('ufo').setup({
provider_selector = function(bufnr, filetype, buftype)
return ftMap[filetype]
end
})
Thanks, but I guess you misunderstand the template. Ahhh.. I am so sorry,
Here is my mini.lua
,
-- Use Vim packages install the plugin, also work with some plugins manager such as packer.nvim
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd('packadd promise-async')
vim.cmd('packadd nvim-ufo')
vim.cmd('packadd nvim-lspconfig')
-- Setting
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true
local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)
local lspconfig = require('lspconfig')
lspconfig.rust_analyzer.setup({})
Considering the same project structure as mentioned earlier, i.e
root/
|-- Cargo.toml
|-- src/
|-- main.rs
|-- module/
|-- mod.rs
|-- file1.rs
lib.rs
by nvim --clean -u ~/mini.lua src/main.rs
,Cargo.toml
, by typing :edit Cargo.toml
, Now neovim complains about the mentioned Issue.Here is a video demonstration of the steps taken,
Hope this gives you a little more reproducibility over the issue.
I can't reproduce even though I clone your repo. nvim with --clean
but still has a tabline conclude that your rtp is not clean enough, maybe a lot of plugins is loaded.
Use nvim --clean +'so ~/mini.lua' +'e src/main.rs'
instead.
Use
nvim --clean +'so ~/mini.lua' +'e src/main.rs'
instead.
Now it works properly, I will try to disable all plugins and enable them one by one to figure out which plugin causes the issue exactly.
Update: Got the exact plugin that causes the conflict with ufo, saecki/crates.nvim causes the conflict, most probably because it opens a new workspace for Cargo.toml
to provide its own auto completion for dependency versions, and at that point it already had a workspace running in the background.
I guess I can simply disable ufo
when I enter a Cargo.toml
, because It isn't even as useful over there since the file itself isn't that huge that it would require folding....
If you have any better suggestion please do tell me...
I guess I can simply disable ufo when I enter a Cargo.toml, because It isn't even as useful over there since the file itself isn't that huge that it would require folding....
Yes, provider_selector
return 'indent'
for Cargo.toml
.
Neovim version (nvim -v | head -n1)
NVIM v0.7.2
Operating system/version
ArchLinux
How to reproduce the issue
This error occurs only if any project is loaded using ahmedkhalf/project.nvim. The error does not appear on opening the first file, but loading any file using either Telescope, or, NvimTree results in this error. Also opening files using the
:edit
works completely fine.Following are the steps to reproduce this issue on my machine:
:Telescope projects
and select any file of any project (so far so good)Here is a video demonstration:
https://user-images.githubusercontent.com/57960301/185751259-f29b75b4-9e4b-4bf4-b660-cf0c6f4b1f65.mp4
The log file is attached below (This log file is a fresh one after deleting the previous one and freshly capturing the error): ufo.log
You can find my configuration over here
Hope this gives you all the information you need. If anything is missing please do let me know and I shall try to provide.
Expected behavior
Expected behavior was to open the file properly and folds to keep working.
Actual behavior
On opening as demonstrated above, I am greeted with the following error:
EDIT: It also seems that the issue could be related to the LSP, more specifically rust-analyaer, which I have setup using rust-tools