# Help with neovim lsp

**URL:** <https://forum.fuel.network/t/help-with-neovim-lsp/5343>\
**Category:** Tooling and IDE\
**Created:** [May 23, 2024, 8:33am UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343 "2024-05-23T08:33:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lokesh-lync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/lokesh-lync/32/2902_2.png) [@lokesh-lync](https://forum.fuel.network/u/lokesh-lync)\
**Post date:** [May 23, 2024, 8:33am UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/1 "2024-05-23T08:33:18Z")

</div>

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](https://github.com/codetit4n/nvim-config/blob/arch/ftplugin/sway.lua)

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.

---

<div class="post-metadata">

**Author:** ![sophie-fuel](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sophie-fuel](https://forum.fuel.network/u/sophie-fuel)\
**Post date:** [May 24, 2024, 4:26pm UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/2 "2024-05-24T16:26:12Z")

</div>

Which version of forc-lsp are you running? There have been many performance improvements in the newer versions of the LSP. See [Troubleshooting](https://docs.fuel.network/docs/nightly/sway/lsp/troubleshooting/)

It looks like you’ve based your config off of [this setup](https://github.com/FuelLabs/sway.vim) 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`:

```auto
	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

```auto
       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!

---

<div class="post-metadata">

**Author:** ![lokesh-lync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/lokesh-lync/32/2902_2.png) [@lokesh-lync](https://forum.fuel.network/u/lokesh-lync)\
**Post date:** [May 27, 2024, 7:50am UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/3 "2024-05-27T07:50:32Z")

</div>

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](https://github.com/codetit4n/nvim-config/blob/arch/lua/codetit4n/init.lua#L23-L27)  
And it works without any issues. You can see my LspInfo here:

 ![Screenshot_select-area_20240527131128](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/a/a96b20b2033f170d8aadff1651ee61d6fc5b48b1.png)

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](https://github.com/codetit4n/nvim-config/blob/arch/lua/codetit4n/lazy/lsp.lua#L80-L101)

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,

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

```

This is working fine

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [May 28, 2024, 7:06am UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/4 "2024-05-28T07:06:53Z")

</div>

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.

 ![telegram-cloud-photo-size-5-6246848946861358720-y](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/7/7bdbb3e3309a5916cbaa921a694569f0dd1ad766.jpeg)

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

---

<div class="post-metadata">

**Author:** ![sophie-fuel](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sophie-fuel](https://forum.fuel.network/u/sophie-fuel)\
**Post date:** [May 31, 2024, 2:39pm UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/5 "2024-05-31T14:39:57Z")

</div>

> [@lokesh-lync](#):
>
> - 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?

In response to your questions,

1. The diagnostics feature is available, yes.
2. Thanks for the screenshot @naz3eh - 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.](https://github.com/FuelLabs/sway) 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.

---

<div class="post-metadata">

**Author:** ![lokesh-lync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/lokesh-lync/32/2902_2.png) [@lokesh-lync](https://forum.fuel.network/u/lokesh-lync)\
**Post date:** [June 5, 2024, 6:16am UTC](https://forum.fuel.network/t/help-with-neovim-lsp/5343/6 "2024-06-05T06:16:57Z")

</div>

Created issue here: [Issues with neovim hover · Issue #6091 · FuelLabs/sway · GitHub](https://github.com/FuelLabs/sway/issues/6091)
