nix-community / vscode-nix-ide

Nix language support for VSCode editor [maintainer: @jnoortheen]
https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide
MIT License
260 stars 20 forks source link

Empty files causing LS to throw errors #393

Open Munsio opened 1 month ago

Munsio commented 1 month ago

Hey running the extension with nixd LS and when I open an empty .nix file I always get a lot of errors inside VSCode because the LS is unable to generate the AST from the file.

Technically it is a valid error from LS but it is very annoying inside VSCode, so I would suggest to suppress this particular error if the file content is empty.

On the other hand if there is a configuration to avoid this behavior, then I would suggest to put it into a "possible default" documentation section or similar.

Error message:

I[12:28:37.526] 2177: <-- textDocument/codeAction(857)
I[12:28:37.526] 2177: --> reply:textDocument/codeAction(857)
I[12:28:37.544] 2177: <-- textDocument/documentLink(858)
I[12:28:37.544] 2177: --> reply:textDocument/documentLink(858) AST is null on this unit, error: 3
I[12:28:37.544] 2177: <-- textDocument/inlayHint(859)
I[12:28:37.544] 2177: --> reply:textDocument/inlayHint(859) AST is null on this unit, error: 3
[Error - 12:28:37 PM] Request textDocument/documentLink failed.
  Message: AST is null on this unit
  Code: -32001 
[Error - 12:28:37 PM] Request textDocument/inlayHint failed.
  Message: AST is null on this unit
  Code: -32001 
I[12:28:37.823] 2177: <-- textDocument/semanticTokens/full(860)
I[12:28:37.823] 2177: --> reply:textDocument/semanticTokens/full(860) AST is null on this unit, error: 3
[Error - 12:28:37 PM] Request textDocument/semanticTokens/full failed.
  Message: AST is null on this unit
  Code: -32001 
I[12:28:37.830] 2177: <-- textDocument/documentSymbol(861)
I[12:28:37.830] 2177: --> reply:textDocument/documentSymbol(861) AST is null on this unit, error: 3
[Error - 12:28:37 PM] Request textDocument/documentSymbol failed.
  Message: AST is null on this unit
  Code: -32001 

If you need anything else just ask and I try to provide all the information needed.

inclyc commented 2 weeks ago

This is fixed in nixd 2.2.2

DylanBulfin commented 23 hours ago

Could be something with my configuration since I'm pretty new to nix(OS), but I'm still seeing the same behavior with nixd 2.2.2 and nix-ide 0.3.1 (both from nixpkgs-unstable)

inclyc commented 18 hours ago

Yes, that's partially fixed (in 2.2.2), you can see the release notes.