nix-community / nixd

Nix language server, based on nix libraries [maintainer=@inclyc,@Aleksanaa]
https://github.com/nix-community/nixd
GNU Lesser General Public License v3.0
923 stars 31 forks source link

Crash on NeoVim, code 0, signal 6 #583

Closed arminveres closed 3 months ago

arminveres commented 3 months ago

Describe the bug When any .nix file is opened the LSP, nixd instantly crashes

Logs (Required)

https://pastebin.com/QcQKANYP

Configuration

local capabilities = vim.lsp.protocol.make_client_capabilities()
local function on_attach(client, bufnr)
    -- enable snipper support
    capabilities.textDocument.completion.completionItem.snippetSupport = true
    -- update default nvim capabilities with those of cmp
    capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
    -- Highlight words under current cursor
    require("illuminate").on_attach(client)
end

local lspconfig = require("lspconfig")

lspconfig.nixd.setup({
    on_attach = on_attach,
    capabilities = capabilities,
    -- even with cmd defaulted, the errors still persist.
    cmd = { "nixd", "--inlay-hints", "--semantic-tokens" },
})

If you have some custom configuration, please paste it here.

To Reproduce Steps to reproduce the behavior:

  1. Open any nix flake
  2. See lsp crashing

Expected behavior LSP not crashing and working

Additional context nixd installed through home-manager on NixOS.

naufik commented 3 months ago

Currently having this issue as well with nixd installed from environment.systemPackages.

Nixd Version 2.1.2. Tracking stable on nixpkgs commit 4a92571f9207810b559c9eac203d1f4d79830073

Seems to crash after the following in the logs:

<-- reply 1
--> notify progress
<-- textDocument/inlineCompletion(3)
--> notify exit
inclyc commented 3 months ago

Open the same buffer with https://github.com/nix-community/nixd/blob/main/nixd/docs/editors/editors.md#reproducible-editors-environment, is it still crashing?

arminveres commented 3 months ago

@inclyc No, that works fine! I tried adding it as an overlay, but the result is still the same.

inclyc commented 3 months ago

@inclyc No, that works fine! I tried adding it as an overlay, but the result is still the same.

I believe the issue was caused by the editor setup. The client (neovim) is sending some non-UTF-8 encoded data to nixd, which results in a crash. Although this shouldn't cause the language server to crash, it can be worked around by fixing the editor configuration (I'm not sure how, but it's definitely possible since other editors are able to work seamlessly).

I guess it is related to your localization settings.

arminveres commented 3 months ago

Alright, thanks. Makes sense, although I have no clue where that may come from.

inclyc commented 3 months ago

Hello @arminveres, I've labeled this issue with cannot-reproduce. If you could provide more details about the problem, preferably using the Nix language, it would be greatly helpful. Or alternatively, if there are no further issues to address, we might consider closing this issue?

arminveres commented 3 months ago

Hi @inclyc, the issue still persists, the only thing I can give, is my nvim config. If I had time, I had to bisect which plugin could cause this issue, but I cannot for the moment.

EDIT: Seems like the plugin that caused the crash was https://github.com/uga-rosa/ccc.nvim. I guess this can be closed now.

ddogfoodd commented 3 months ago

Ah, I recently installed this plugin and also get this error. So should we open an issue there?

inclyc commented 3 months ago

EDIT: Seems like the plugin that caused the crash was https://github.com/uga-rosa/ccc.nvim. I guess this can be closed now.

Thanks.