Home Explore Blog CI



neovim

38th chunk of `runtime/doc/lsp.txt`
c7eaf0053404370d6f5e31fb3c490cc6519bba44e34174ef0000000100000fda
 |window-ID| or 0 for current,
                             defaults to current
      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)

    Return: ~
        (`lsp.TextDocumentPositionParams`)

    See also: ~
      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams

                                            *vim.lsp.util.make_range_params()*
make_range_params({window}, {position_encoding})
    Using the current position in the current buffer, creates an object that
    can be used as a building block for several LSP requests, such as
    `textDocument/codeAction`, `textDocument/colorPresentation`,
    `textDocument/rangeFormatting`.

    Parameters: ~
      • {window}             (`integer?`) |window-ID| or 0 for current,
                             defaults to current
      • {position_encoding}  (`"utf-8"|"utf-16"|"utf-32"`)

    Return: ~
        (`{ textDocument: { uri: lsp.DocumentUri }, range: lsp.Range }`)

                                    *vim.lsp.util.make_text_document_params()*
make_text_document_params({bufnr})
    Creates a `TextDocumentIdentifier` object for the current buffer.

    Parameters: ~
      • {bufnr}  (`integer?`) Buffer handle, defaults to current

    Return: ~
        (`lsp.TextDocumentIdentifier`)

    See also: ~
      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier

                                        *vim.lsp.util.make_workspace_params()*
make_workspace_params({added}, {removed})
    Create the workspace params

    Parameters: ~
      • {added}    (`lsp.WorkspaceFolder[]`)
      • {removed}  (`lsp.WorkspaceFolder[]`)

    Return: ~
        (`lsp.DidChangeWorkspaceFoldersParams`)

                                        *vim.lsp.util.open_floating_preview()*
open_floating_preview({contents}, {syntax}, {opts})
    Shows contents in a floating window.

    Parameters: ~
      • {contents}  (`table`) of lines to show in window
      • {syntax}    (`string`) of syntax to set for opened buffer
      • {opts}      (`vim.lsp.util.open_floating_preview.Opts?`) with optional
                    fields (additional keys are filtered with
                    |vim.lsp.util.make_floating_popup_options()| before they
                    are passed on to |nvim_open_win()|). See
                    |vim.lsp.util.open_floating_preview.Opts|.

    Return (multiple): ~
        (`integer`) bufnr of newly created float window
        (`integer`) winid of newly created float window preview window

preview_location({location}, {opts})         *vim.lsp.util.preview_location()*
    Previews a location in a floating window

    behavior depends on type of location:
    • for Location, range is shown (e.g., function definition)
    • for LocationLink, targetRange is shown (e.g., body of function
      definition)

    Parameters: ~
      • {location}  (`lsp.Location|lsp.LocationLink`)
      • {opts}      (`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},

Title: vim.lsp.util - Functions for LSP Requests, Workspace, and Preview
Summary
This section describes functions in `vim.lsp.util` related to building LSP requests, handling workspace folders, and displaying previews. It covers functions for creating `TextDocumentPositionParams` and range parameters (`make_position_params`, `make_range_params`), creating a `TextDocumentIdentifier` object (`make_text_document_params`), creating workspace parameters (`make_workspace_params`), opening floating preview windows (`open_floating_preview`, `preview_location`), renaming files (`rename`), and showing documents (`show_document`).