mattn / efm-langserver

General purpose Language Server
MIT License
1.34k stars 61 forks source link

RPC[ERROR] parse "": empty url [neovim] #184

Closed ViRu-ThE-ViRuS closed 2 years ago

ViRu-ThE-ViRuS commented 2 years ago
local efm_prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true}
lsp["efm"].setup {
    capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),
    init_options = {documentFormatting = true},
    filetypes = {
        "css",
        "html",
        "javascript",
        "javascriptreact",
        "json",
        "lua",
        "markdown",
        "python"
    },
    settings = {
        rootMarkers = {".git/"},
        languages = {
            css = {efm_prettier},
            html = {efm_prettier},
            javascript = {efm_prettier},
            javascriptreact = {efm_prettier},
            json = {efm_prettier},
            lua = {{formatCommand = "luafmt --stdin", formatStdin = true}},
            markdown = {efm_prettier},
            python = {{formatCommand = "autopep8 -", formatStdin = true}}
        }
    },
    on_attach = function(client, buffer_nr)
        if client.resolved_capabilities.document_formatting then
            utils.map('n','<c-f>', '<cmd>lua vim.lsp.buf.formatting()<cr>', { silent = true }, buffer_nr)
        end

        if client.resolved_capabilities.document_range_formatting then
            utils.map('v','<c-f>', '<cmd>lua vim.lsp.buf.range_formatting()<cr>', { silent = true }, buffer_nr)
        end
    end
}

lspconfig-setup ^ using: neovim HEAD, efm 0.0.37

Just started getting this error after updating to neovim HEAD this morning. Have no changes in config, empty efm-langserver/config.yaml file (this has worked fine for months).

Downgrading to neovim stable 0.5.1 also gives the same error, and lsp log gives:

[ERROR][2021-11-11 15:16:52] .../vim/lsp/rpc.lua:412    "rpc"   "efm-langserver"    "stderr"    "2021/11/11 15:04:46 efm-langserver: reading on stdin, writing on stdout\n"
[ERROR][2021-11-11 15:16:53] .../lua/vim/lsp.lua:734    "LSP[sumneko_lua]"  "on_error"  {  code = "SERVER_REQUEST_HANDLER_ERROR",  err = "...AD-2ef9d2a_1/share/nvim/runtime/lua/vim/lsp/handlers.lua:74: attempt to index local 'client' (a nil value)"}

NOTE: the second error line about indexing client nil value, only happens sometimes.

The EFM server doesn't attach to any buffer it is configured for because of this exit code. Full Error is:

Error executing vim.schedule lua callback: ...neovim/HEAD-2ef9d2a_1/share/nvim/runtime/lua/vim/lsp.lua:859: RPC[Error] code_name = unknown, code = 0, message = "parse \"\": empty url"
stack traceback:
        [C]: in function 'assert'
        ...neovim/HEAD-2ef9d2a_1/share/nvim/runtime/lua/vim/lsp.lua:859: in function 'cb'
        vim.lua:285: in function <vim.lua:285>

neovim HEAD vim/lsp.lua:859

ViRu-ThE-ViRuS commented 2 years ago

SOLVED

for anyone facing similar issues with efm, add this line to your efm lspconfig:

root_dir = require("lspconfig").util.root_pattern{".git/", "."},