Home Explore Blog CI



neovim

40th chunk of `runtime/doc/lsp.txt`
9c329cff249569601e6fbe99d7b6ecbbf1bf16d3eed809880000000100000e63
 "ERROR" messages containing "stderr" only indicate that the log was sent to
  stderr. Many servers send harmless messages via stderr.


get_filename()                                    *vim.lsp.log.get_filename()*
    Returns the log filename.

    Return: ~
        (`string`) log filename

get_level()                                          *vim.lsp.log.get_level()*
    Gets the current log level.

    Return: ~
        (`integer`) current log level

set_format_func({handle})                      *vim.lsp.log.set_format_func()*
    Sets the formatting function used to format logs. If the formatting
    function returns nil, the entry won't be written to the log file.

    Parameters: ~
      • {handle}  (`fun(level:string, ...): string?`) Function to apply to log
                  entries. The default will log the level, date, source and
                  line number of the caller, followed by the arguments.

set_level({level})                                   *vim.lsp.log.set_level()*
    Sets the current log level.

    Parameters: ~
      • {level}  (`string|integer`) One of |vim.log.levels|


==============================================================================
Lua module: vim.lsp.rpc                                              *lsp-rpc*

*vim.lsp.rpc.PublicClient*
    Client RPC object

    Fields: ~
      • {request}     (`fun(method: string, params: table?, callback: fun(err?: lsp.ResponseError, result: any), notify_reply_callback?: fun(message_id: integer)):boolean,integer?`)
                      See |vim.lsp.rpc.request()|
      • {notify}      (`fun(method: string, params: any): boolean`) See
                      |vim.lsp.rpc.notify()|
      • {is_closing}  (`fun(): boolean`) Indicates if the RPC is closing.
      • {terminate}   (`fun()`) Terminates the RPC client.


connect({host_or_path}, {port})                        *vim.lsp.rpc.connect()*
    Create a LSP RPC client factory that connects to either:
    • a named pipe (windows)
    • a domain socket (unix)
    • a host and port via TCP

    Return a function that can be passed to the `cmd` field for
    |vim.lsp.start()|.

    Parameters: ~
      • {host_or_path}  (`string`) host to connect to or path to a pipe/domain
                        socket
      • {port}          (`integer?`) TCP port to connect to. If absent the
                        first argument must be a pipe

    Return: ~
        (`fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient`)

format_rpc_error({err})                       *vim.lsp.rpc.format_rpc_error()*
    Constructs an error message from an LSP error object.

    Parameters: ~
      • {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)`)
                               

Title: vim.lsp.log continued and vim.lsp.rpc
Summary
The section continues with the `vim.lsp.log` module, specifically covering the `set_level` function which sets the current log level. Following this, the documentation transitions to the `vim.lsp.rpc` module. This module deals with Remote Procedure Calls (RPC) for the Language Server Protocol (LSP). It defines the `PublicClient` object, and provides functions for connecting to an LSP server (`connect`), formatting RPC errors (`format_rpc_error`), sending notifications (`notify`), and sending requests (`request`).