Home Explore Blog CI



neovim

39th chunk of `runtime/doc/lsp.txt`
0ca782878c94bfb2e0d5504e60c8118782a38b851d2fd4070000000100000fdd
 (`vim.lsp.util.open_floating_preview.Opts?`) See
                    |vim.lsp.util.open_floating_preview.Opts|.

    Return (multiple): ~
        (`integer?`) buffer id of float window
        (`integer?`) window id of float window

rename({old_fname}, {new_fname}, {opts})               *vim.lsp.util.rename()*
    Rename old_fname to new_fname

    Existing buffers are renamed as well, while maintaining their bufnr.

    It deletes existing buffers that conflict with the renamed file name only
    when
    • `opts` requests overwriting; or
    • the conflicting buffers are not loaded, so that deleting them does not
      result in data loss.

    Parameters: ~
      • {old_fname}  (`string`)
      • {new_fname}  (`string`)
      • {opts}       (`table?`) Options:
                     • {overwrite}? (`boolean`)
                     • {ignoreIfExists}? (`boolean`)

                                                *vim.lsp.util.show_document()*
show_document({location}, {position_encoding}, {opts})
    Shows document and optionally jumps to the location.

    Parameters: ~
      • {location}           (`lsp.Location|lsp.LocationLink`)
      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'?`)
      • {opts}               (`table?`) A table with the following fields:
                             • {reuse_win}? (`boolean`) Jump to existing
                               window if buffer is already open.
                             • {focus}? (`boolean`) Whether to focus/jump to
                               location if possible. (defaults: true)

    Return: ~
        (`boolean`) `true` if succeeded

                                             *vim.lsp.util.symbols_to_items()*
symbols_to_items({symbols}, {bufnr}, {position_encoding})
    Converts symbols to quickfix list items.

    Parameters: ~
      • {symbols}            (`lsp.DocumentSymbol[]|lsp.SymbolInformation[]`)
                             list of symbols
      • {bufnr}              (`integer?`) buffer handle or 0 for current,
                             defaults to current
      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'?`) default to first
                             client of buffer

    Return: ~
        (`vim.quickfix.entry[]`) See |setqflist()| for the format


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

The `vim.lsp.log` module provides logging for the Nvim LSP client.

When debugging language servers, it is helpful to enable extra-verbose logging
of the LSP client RPC events. Example: >lua
    vim.lsp.set_log_level 'trace'
    require('vim.lsp.log').set_format_func(vim.inspect)
<

Then try to run the language server, and open the log with: >vim
    :lua vim.cmd('tabnew ' .. vim.lsp.get_log_path())
<

(Or use `:LspLog` if you have nvim-lspconfig installed.)

Note:
• Remember to DISABLE verbose logging ("debug" or "trace" level), else you may
  encounter performance issues.
• "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()*

Title: vim.lsp.util - Showing Documents, Converting Symbols, and vim.lsp.log - Logging for LSP Client
Summary
This section covers the remaining functions in `vim.lsp.util`, including showing a document and optionally jumping to a location (`show_document`) and converting symbols to quickfix list items (`symbols_to_items`). The section then transitions to the `vim.lsp.log` module, which provides logging capabilities for the Nvim LSP client. It discusses how to enable verbose logging for debugging, cautions about performance issues with excessive logging, and describes functions for getting the log filename (`get_filename`), getting the current log level (`get_level`), setting the log formatting function (`set_format_func`), and setting the log level (`set_level`).