dalance / svls

SystemVerilog language server
MIT License
466 stars 31 forks source link

Use svls with Neovim lsp #29

Closed dpretet closed 3 years ago

dpretet commented 3 years ago

Hi,

I'm very interesting to use your language server with the brand new LSP of Neovim. I made a pull request here:

https://github.com/neovim/nvim-lspconfig/pull/477

However, even of the server sounds well configured from Neovim point of view, I don't see back information when opening a systemverilog file. I dropped into .svls.toml the following setup:

[verilog]
include_paths = ["src"]
defines = ["DEBUG"]

[option]
linter = true

How could I debug the server? Any log I can find and parse to understand the issue?

Best, Damien

dalance commented 3 years ago

Thank you for your interesting in svls. -d option may be useful. If it is used, svls will output svls.log to the repository root. Could you try below?

cmd = { "svls", "-d" },

--stdio is not a valid option for svls. I think it is not required.

dpretet commented 3 years ago

Thanks for the fast feedback! Don't know where I found this --stdio, most likely a clumsy copy/paste from another config. Anyway, I changed with your recommendation and now I see the log file:

10:13:39 [DEBUG] (1) svls: start
10:13:39 [DEBUG] (1) svls::backend: root_uri: Some(Url { scheme: "file", host: None, port: None, path: "/Users/damien/workspace/hdl/bster/src", query: None, fragment: None })
10:13:39 [DEBUG] (1) svls::backend: config_svls: Some("/Users/damien/workspace/hdl/bster/.svls.toml")
10:13:39 [DEBUG] (1) svls::backend: config_svlint: Some("/Users/damien/workspace/hdl/bster/.svlint.toml")
10:13:39 [INFO] language server initialized
10:13:39 [DEBUG] (1) svls::backend: did_open
10:13:39 [DEBUG] (1) svls::backend: include_paths: []
10:13:39 [DEBUG] (1) svls::backend: defines: {}
10:13:39 [DEBUG] (1) svls::backend: parse_error: Include { source: File { source: Os { code: 2, kind: NotFound, message: "No such file or directory" }, path: "bster_h.sv" } }

bster_h.sv is supposed to be in src folder I point with svls.toml.

dalance commented 3 years ago
10:13:39 [DEBUG] (1) svls::backend: include_paths: []
10:13:39 [DEBUG] (1) svls::backend: defines: {}

This shows include path and define are not loaded from .svls.toml. Is the content of /Users/damien/workspace/hdl/bster/.svls.toml the code of the first description?

dpretet commented 3 years ago

Yes it is, I saw this issue but don't know how to solve that.

dalance commented 3 years ago

Could you try this binary? I added config parse failure to log.

svls.zip

dpretet commented 3 years ago

I tried but nothing is dropped, I see this message trying to execute the file:

zsh: exec format error: ./svls

I forgot to mention I'm testing on MacOS

dalance commented 3 years ago

Ok. Could you upload your .svls.toml?

dpretet commented 3 years ago

Here it is. I joined also svls.lua to drop in Nvim-lsplua/lspconfig in case you want to try with Neovim LSP engine.

Archive.zip

Thanks for the support!

dalance commented 3 years ago

I found typo.

# should be [verilog]
[veriog]
include_paths = ["./src"]
defines = ["DEBUG"]

[option]
linter = true
dpretet commented 3 years ago

sorry for the stupid mistake, crazy frustrating I didn't see that. Now I'm able to move forward after this fix and an update to the nvim-lsp file to point to the git root of a repository.

Now when I write an error into my SystemVerilog code, I can see a "parse error" indication aside the line "module MyModuleName" (b ut it's the only one) and an information of the line number in svls.log.

13:15:39 [DEBUG] (1) svls::backend: include_paths: ["/Users/damien/workspace/hdl/bster/src"]
13:15:39 [DEBUG] (1) svls::backend: defines: {"DEBUG": Some(Define { identifier: "DEBUG", arguments: [], text: None })}
13:15:39 [DEBUG] (1) svls::backend: parse_error: Parse(Some(("", 190)))
dalance commented 3 years ago

Don't worry. I'm relived that it is not platfrom specifc issue. I'll add error indication for unknown field of TOML.

dpretet commented 3 years ago

I removed my svlint.toml and so all checks are performed. Now I can see the messages over the file, right along the lines 👍🏻

image

Thanks for your help, the pull request is on its way and you'll be officially supported by Neovim 0.5 (at least I hope :) ) as sv language server.

Thanks for your work and your great software! 🥇

dpretet commented 3 years ago

Hello,

it's me again :) I played with Neovim 0.5 + LSP + svls and I still encounter an issue. With your help, I've been able to launch the server and make it lint the code. However when the file is modified, by adding a empty line or correcting with svlint suggestion, all the suggestions disappear and never come back. Relaunching Neovim is the only solution get back the suggestion.

Any idea how to debug that and understand the issue? I tried with several files and passing them into svlint directly or into Verilator not reveal error, only warning.

I attached the svls log describing a file opening, a change then I close Neovim.

svls.log.zip

dalance commented 3 years ago

In my environment, Neovim 0.5 + dpretet/nvim-lspconfig works fine. Which revision do you use? I'm now f007a140a.

dpretet commented 3 years ago

Hi Dalance,

I think I understood my issue, I installed the nvim lspconfig with Vim-Plug, but it sounds to be updated. Into this one, I dropped my svls.lua file and most likely I was on an old version. Don't why Vim-Plug used a commit from November 21th...

Anyway, thanks again for you help!