API Reference

All functions are available via the require string:

local gp = require('goto-preview')

Core Preview Functions

These functions trigger the LSP request and open the floating window.

goto_preview_definition(opts)

Requests textDocument/definition.

goto_preview_type_definition(opts)

Requests textDocument/typeDefinition.

goto_preview_implementation(opts)

Requests textDocument/implementation.

goto_preview_declaration(opts)

Requests textDocument/declaration.

goto_preview_references(opts)

Requests textDocument/references. If multiple references are returned, the configured provider (see Configuration) is used to select one.

Arguments:

  • opts (table, optional): A table allowing one-off overrides for this specific call.
    • focus_on_open (boolean)
    • dismiss_on_move (boolean)

Window Management

close_all_win(options)

Closes all floating windows managed by this plugin.

Arguments:

  • options (table, optional):
    • skip_curr_window (boolean): If true, closes all preview windows except the one currently focused.

Example:

require("goto-preview").close_all_win { skip_curr_window = true }

dismiss_preview(winnr)

Dismisses a specific preview window or all windows if winnr is nil.

Internal/Utility

setup(conf)

Initializes the plugin with the user configuration.

buffer_entered() / buffer_left()

Internal functions used by autocommands to trigger hooks when navigating between buffers.