Home Explore Blog CI



neovim

41th chunk of `runtime/doc/lsp.txt`
d3919eed079ec8cb3cb0ef360dcd533627dd9e478b719c85000000010000092c
 ~
      • {err}  (`table`) The error object

    Return: ~
        (`string`) error_message The formatted error message

notify({method}, {params})                              *vim.lsp.rpc.notify()*
    Sends a notification to the LSP server.

    Parameters: ~
      • {method}  (`string`) The invoked LSP method
      • {params}  (`table?`) Parameters for the invoked LSP method

    Return: ~
        (`boolean`) `true` if notification could be sent, `false` if not

                                                       *vim.lsp.rpc.request()*
request({method}, {params}, {callback}, {notify_reply_callback})
    Sends a request to the LSP server and runs {callback} upon response.

    Parameters: ~
      • {method}                 (`string`) The invoked LSP method
      • {params}                 (`table?`) Parameters for the invoked LSP
                                 method
      • {callback}               (`fun(err: lsp.ResponseError?, result: any)`)
                                 Callback to invoke
      • {notify_reply_callback}  (`fun(message_id: integer)?`) Callback to
                                 invoke as soon as a request is no longer
                                 pending

    Return (multiple): ~
        (`boolean`) success `true` if request could be sent, `false` if not
        (`integer?`) message_id if request could be sent, `nil` if not

                                            *vim.lsp.rpc.rpc_response_error()*
rpc_response_error({code}, {message}, {data})
    Creates an RPC response table `error` to be sent to the LSP response.

    Parameters: ~
      • {code}     (`integer`) RPC error code defined, see
                   `vim.lsp.protocol.ErrorCodes`
      • {message}  (`string?`) arbitrary message to send to server
      • {data}     (`any?`) arbitrary data to send to server

    Return: ~
        (`lsp.ResponseError`)

    See also: ~
      • lsp.ErrorCodes See `vim.lsp.protocol.ErrorCodes`

start({cmd}, {dispatchers}, {extra_spawn_params})        *vim.lsp.rpc.start()*
    Starts an LSP server process and create an LSP RPC client object to
    interact with it. Communication with the spawned process happens via
    stdio. For communication via TCP, spawn a process manually and use
    |vim.lsp.rpc.connect()|

    Parameters: ~
      • {cmd}          

Title: vim.lsp.rpc continued
Summary
This section continues the documentation for `vim.lsp.rpc`, focusing on the `request` function, which sends a request to the LSP server and executes a callback upon receiving the response. It also describes `rpc_response_error`, which creates an RPC response error table for sending to the LSP server, using error codes defined in `vim.lsp.protocol.ErrorCodes`. Finally, it introduces the `start` function, which starts an LSP server process and creates an LSP RPC client to interact with it via stdio, recommending `vim.lsp.rpc.connect()` for TCP communication.