Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Neovim] Doesn't work after 3.6.8 -- keep loading workspaces #1872

Closed
rockyzhang24 opened this issue Feb 2, 2023 · 27 comments
Closed

[Neovim] Doesn't work after 3.6.8 -- keep loading workspaces #1872

rockyzhang24 opened this issue Feb 2, 2023 · 27 comments
Labels
bug Something isn't working Info Needed More information is required

Comments

@rockyzhang24
Copy link

rockyzhang24 commented Feb 2, 2023

How are you using the lua-language-server?

NeoVim

Which OS are you using?

MacOS

What is the issue affecting?

Other

Expected Behaviour

It should work normally.

Actual Behaviour

The server doesn't work.

Reproduction steps

This issue occurred after I upgraded this lua-language-server to 3.6.8.

Config the server as Neovim instructs here: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua

require'lspconfig'.sumneko_lua.setup {
  settings = {
    Lua = {
      runtime = {
        version = 'LuaJIT',
      },
      workspace = {
        library = vim.api.nvim_get_runtime_file("", true),
      },
      telemetry = {
        enable = false,
      },
    },
  },
}

I opened any Lua file, the lsp progress showed "loading workspace" and it lasted forever. Then I quitted Neovim but lua-language-server process is stilling running in the background. Next, I tried to remove workspace = {} in the config above and the issue was gone.

Another issue is: if I placed a .luarc.jsonc file (even if it is empty) under by Neovim config directory, ~/.config/nvim/.luarc.json, and then I opened a Lua file under this directory, ~/.config/nvim/lua/test.lua, the LSP server doesn't work neither. However, it works well in version 3.6.7.

By further investigation and testing, I found that this issue happens if the directory is large (the nvim directory has many subdirectories because I have plugins installed in nvim/pack/start/). In version 3.6.7, it may took a little time (a couple of seconds) for the Lua server to be ready to work, however, in version 3.6.8 and 3.6.9, it kept loading the workspace and it is still there after two minutes.

Update:
this time I opened a Lua file and then hung in there. It took about 5 minutes for the LSP server to initialize. Within this period, no auto-complete, no diagnostics, and after the initialization, everything works fine.

Thank you very much.

Additional Notes

No response

Log File

No response

@sumneko sumneko added bug Something isn't working Info Needed More information is required labels Feb 3, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

I wonder there is a bad symlink in your workspace, I will try to check it.

@rockyzhang24
Copy link
Author

Thank you so much for investigating. The workspace is just my Neovim config plus all the plugins I installed. If there is a bad symlink, it must belong to some plugin, but generally speaking the plugin author won't put a symlink there. I have no ideas. However, everything worked well in version 3.6.7.

@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

@rockyzhang24
Copy link
Author

Sure. Let me see where I can find the log file if I am using Neovim. Thanks.

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 3, 2023

@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

I found this:

[23:03:11.289][info] [#0:script/workspace/workspace.lua:332]: Scan library at:	file:///Users/rockyzhang/.config/nvim
[23:06:45.463][warn] [#0:script/await.lua:195]: [fire]Await step takes [61.262] sec.
stack traceback:
	[C]: in function 'coroutine.yield'
	script/await.lua:171: in function 'await.delay'
	script/workspace/loading.lua:147: in method 'loadFile'
	script/workspace/workspace.lua:346: in upvalue 'callback'
	script/glob/gitignore.lua:178: in local 'check'
	script/glob/gitignore.lua:208: in method 'scan'
	script/workspace/workspace.lua:343: in function 'workspace.workspace.awaitPreload'
	script/workspace/workspace.lua:517: in function 'workspace.workspace.awaitReload'
	script/workspace/workspace.lua:464: in function <script/workspace/workspace.lua:463>

Here is a file:///Users/rockyzhang/.config/nvim in your workspace/library, and it seems so many files in this path, please check your config.

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 3, 2023

As I said, /Users/rockyzhang/.config/nvim/ is the directory for my Neovim configuration. It contains my personal settings and all the plugins I installed. I use this whole directory as the workspace by setting workspace.library = /path/to/that/dir/ as recommended by Neovim (here: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua). By doing so, the auto-complete will offer all the APIs of the plugins, and most Neovim users may set in this way.

Before 3.6.8, there was no errors even though the whole waiting time was around a couple of seconds (actually it is not too long for a large workspace). However, after upgrading to 3.6.8 and 3.6.9, the waiting time extends to 4-5 minutes. I reported this issue because it worked totally well before but had issues right after I upgraded it to a new version.

Thank you very much.

@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

Check your workspace/library, it both contains .config/nvim and .config/nvim/pack/*.
So I don't think .config/nvim is necessary.

How many files in workspace/library ?

sumneko added a commit that referenced this issue Feb 3, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

Please update the latest version, and provide your new log with --loglevel=trace

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 3, 2023

This is the config for Lua server

nvim_lsp.sumneko_lua.setup {
  on_attach = on_attach,
  capabilities = capabilities,
  settings = {
    Lua = {
      runtime = {
        version = 'LuaJIT',
      },
      workspace = {
        library = vim.api.nvim_get_runtime_file("", true),
        checkThirdParty = false,
      },
      telemetry = {
        enable = false,
      },
    },
  },
}

vim.api.nvim_get_runtime_file("", true) outputs all the directories Neovim will scan to load plugins. The output is ~/.config/nvim, ~/.config/nvim/pack/minpac/start/fzf, and etc. I didn't change anything after I upgraded it to 3.6.8, but no issues before.

Please update the latest version, and provide your new log with --loglevel=trace

Okay.

@rockyzhang24
Copy link
Author

I built it via the latest commit (42bad3f). This time, I have been waiting for 10 min but it is still at "Loading Workspace". Here is the log so far https://gist.github.com/rockyzhang24/b91385253b6cac1e20b4319c5ba71976

Really appreciate your help and patience.

sumneko added a commit that referenced this issue Feb 3, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

Could you please try this patch?

@rockyzhang24
Copy link
Author

Sure. I cloned and rebuilt it. The issue was still existing. Waited for around 6 min and it was still unfinished. Here is the log https://gist.github.com/rockyzhang24/95a5c1101b83d07a16760b559da3b433

Thanks.

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 3, 2023

Will go to sleep and be back as soon as I get up. If you need a log generated by version 3.6.7 for a comparison, just let me know and I will install it and send you later.

@sumneko
Copy link
Collaborator

sumneko commented Feb 3, 2023

Thank you for your helping!

sumneko added a commit that referenced this issue Feb 4, 2023
@sumneko sumneko closed this as completed in 9ba615e Feb 4, 2023
@sumneko sumneko reopened this Feb 4, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 4, 2023

Please try the latest master

@rockyzhang24
Copy link
Author

Wow, it gets improved a lot. It just took around 15 seconds. I think it is kinda acceptable for a large directory, but I am not sure whether it still has room for improvement. I attached the newly-generated log below for your reference.

https://gist.github.com/rockyzhang24/5601f95da698edaf28b6b4c8d2181a5a

Thank you so much.

@sumneko
Copy link
Collaborator

sumneko commented Feb 4, 2023

but I am not sure whether it still has room for improvement

Yes, we are still disccusing this.

@rockyzhang24
Copy link
Author

Great! In the previous version 3.6.7, the period is shorter, like around 8-10 seconds.

sumneko added a commit that referenced this issue Feb 4, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 4, 2023

Please try this patch

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 4, 2023

I did it but it still took around 17 seconds to finish. I attached the log below

https://gist.github.com/rockyzhang24/9f6bfadaa70cb4d4dedbebdb3e7e4e24

Thanks a lot.

sumneko added a commit that referenced this issue Feb 6, 2023
@sumneko
Copy link
Collaborator

sumneko commented Feb 6, 2023

Please try this commit.
Need to recompile binaries.

sumneko added a commit that referenced this issue Feb 6, 2023
@rockyzhang24
Copy link
Author

That's AMAZING! It just took 5-6 seconds. I also attached the log below for you to see whether you think it still has room to improve.

https://gist.github.com/rockyzhang24/87056f42c64fd6267447042739b6c03a

Btw, based on the results returned from LSP progress, I noticed "Loading Workspace" and "Diagnosing Workspace" are two separate steps. Is it normal? Please check the demo below.

Screen.Recording.2023-02-06.at.09.41.10.mov

Thank you very much.

@sumneko
Copy link
Collaborator

sumneko commented Feb 6, 2023

I noticed "Loading Workspace" and "Diagnosing Workspace" are two separate steps. Is it normal?

Yes. Diagnosing Workspace is just diagnostic feature, you can disable it.

@sumneko sumneko closed this as completed in fa89ccc Feb 6, 2023
@rockyzhang24
Copy link
Author

Yes. Diagnosing Workspace is just diagnostic feature, you can disable it.

Okay I see.

So, now the start-up time (around 5-6 seconds), in your opinion, is good enough for a large folder, right?

@rockyzhang24
Copy link
Author

Really appreciate your patience and efforts 👍

@sumneko
Copy link
Collaborator

sumneko commented Feb 6, 2023

I also thank you very much for keep helping me test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Info Needed More information is required
Projects
None yet
Development

No branches or pull requests

2 participants