ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.44k stars 97 forks source link

`UnicodeDecodeError` with lua_language_server #546

Open phat-sumo opened 1 year ago

phat-sumo commented 1 year ago

When using coq with the sumneko/lua_language_server, I've been experiencing crashes when I write = in insert mode.

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/coq/__main__.py",
line 173, in <module>
    arun(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/coq/__main__.py",
line 171, in main
    await init(args.socket, ppid=args.ppid)
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/coq/client.py", li
ne 70, in init
    async with conn(socket, default=_default) as client:
  File "/usr/lib/python3.10/contextlib.py", line 206, in __aexit__
    await anext(self.gen)
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/.vars/runtime/lib/
python3.10/site-packages/pynvim_pp/nvim.py", line 249, in conn
    async with client(socket, default=default) as rpc:
  File "/usr/lib/python3.10/contextlib.py", line 206, in __aexit__
    await anext(self.gen)
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/.vars/runtime/lib/
python3.10/site-packages/pynvim_pp/rpc.py", line 253, in client
    await conn
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/.vars/runtime/lib/
python3.10/site-packages/pynvim_pp/rpc.py", line 143, in _connect
    await gather(rx(recv()), send())
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/.vars/runtime/lib/
python3.10/site-packages/pynvim_pp/rpc.py", line 188, in rx
    async for frame in rx:
  File "/home/phat_sumo/.local/share/nvim/site/pack/paqs/start/coq_nvim/.vars/runtime/lib/
python3.10/site-packages/pynvim_pp/rpc.py", line 140, in recv
    for frame in unpacker:
  File "msgpack/_unpacker.pyx", line 540, in msgpack._cmsgpack.Unpacker.__next__
  File "msgpack/_unpacker.pyx", line 463, in msgpack._cmsgpack.Unpacker._unpack
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 5: invalid start byte

Relevant pieces of my conf:

-- auto-start coq
-- settings need to come before loading the plugin
vim.g.coq_settings = {
    auto_start = 'shut-up',
    keymap = {
        eval_snips = '<leader>j',
    },
    display = {
        preview = {
            border = border,
        },
        icons = {
            mode = "none",
        },
    },
}

local lsp = require('lspconfig')
local coq = require('coq')

lsp['sumneko_lua'].setup(
    coq.lsp_ensure_capabilities({
        on_attach = on_attach,
        flags = lsp_flags,
        settings = {
            Lua = {
                runtime = {
                    -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
                    version = 'LuaJIT',
                },
                diagnostics = {
                    -- Get the language server to recognize the `vim` global
                    globals = { 'vim' },
                },
                workspace = {
                    -- Make the server aware of Neovim runtime files
                    library = vim.api.nvim_get_runtime_file("", true),
                    checkThirdParty = false,
                },
                -- Do not send telemetry data containing a randomized but unique identifier
                telemetry = {
                    enable = false,
                },
            },
        },
    })
)

All it takes for me to reproduce this crash is having coq and nvim-lspconfig installed with config. When I try to modify my sumneko configuration (usually triggered on inserting =), I get the nasty stack trace from above. I've been stumped on this one for a bit. Any ideas about what might be causing it?

phat-sumo commented 1 year ago

Didn't realize before, but #539 is probably related.

laomaiweng commented 1 year ago

I think I figured it out: https://github.com/ms-jpq/pynvim_pp/pull/5