Help with neovim lsp

Can someone help me debug issues with my forc-lsp setup on neovim. This is how I have set it up: nvim-config/ftplugin/sway.lua at arch · codetit4n/nvim-config · GitHub

Problems:

  1. Most of the times go to def does not work
  2. It takes a lot of time to start the lsp after opening a sway file.
1 Like

Which version of forc-lsp are you running? There have been many performance improvements in the newer versions of the LSP. See Troubleshooting

It looks like you’ve based your config off of this setup already, but I don’t see the ftdetect file which is what tells nvim that file names ending in .sw should trigger the sway LSP. I’m wondering if the slowness starting the server is due to the way you’re detecting sway files in ftplugin:

	root_dir = vim.fs.dirname(vim.fs.find({ "Forc.toml" }, { upward = true })[1]),

The vim.fs.find operation is probably not as efficient as detecting sway files based on the file prefix .sw

If it’s still slow on the latest version, it would be helpful if you can share the LSP trace logs. To do that, start the LSP server with

       init_options = { 
         -- Any initialization options
         logging = { level = 'trace' }
         trace = { server = 'verbose' }
       },

You can use print(vim.lsp.get_log_path()) to get the location of the LSP logs on your machine. I hope this helps!

1 Like

Hey @sophie-fuel thanks for replying.
Regarding detecting file type. I am doing it like this: nvim-config/lua/codetit4n/init.lua at arch · codetit4n/nvim-config · GitHub
And it works without any issues. You can see my LspInfo here:

I did some changes to my config over the weekend and was able to get a few things working:

  • Lsp startup time is better now.
  • I am able to use go to def and hover (mostly).
  • There are no diagnostics.

This is my updated config for forc-lsp: nvim-config/lua/codetit4n/lazy/lsp.lua at arch · codetit4n/nvim-config · GitHub

I have a few questions:

  • Is the diagnostics feature available on forc-lsp?

  • I am getting this wierd hover output in some cases: Will send the screenshot later since I am not able to send more than one screenshot.

  • Regarding version of forc-lsp: Since I use fuel-toolchain.toml Won’t the version of forc-lsp change when this file is present in the directory?

Also,

root_dir = vim.fs.dirname(vim.fs.find({ "Forc.toml" }, { upward = true })[1]),

This is working fine

Hey @sophie-fuel, this is the screenshot from @lokesh-lync and he is not able to reply to this as he has been flagged. This raw data or output appears on hovering over the type.

Can you please help out here? Also, any idea how we can unflag him?

In response to your questions,

  1. The diagnostics feature is available, yes.
  2. Thanks for the screenshot @Nazeeh21 - It looks like a legitimate bug. The server is replying with commands that are implemented in VSCode but not in nvim. Feel free to open an issue for this in GitHub - FuelLabs/sway: 🌴 Empowering everyone to build reliable and efficient smart contracts. and tag me, or I will open one.
  3. Could you link me to your fuel-toolchain.toml? Or, say what version it is defining for forc-lsp?
    nvim should use the version from fuel-toolchain.toml if you are launching nvim from the directory where the toml file is.
1 Like

Created issue here: Issues with neovim hover · Issue #6091 · FuelLabs/sway · GitHub

1 Like