Configuration

You can configure the plugin by passing a table to the setup function. If you are using lazy.nvim with config = true, the default defaults are used.

Default Configuration

Below is the complete list of options with their default values:

require('goto-preview').setup {
  width = 120, -- Width of the floating window
  height = 15, -- Height of the floating window
  border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}, -- Border characters of the floating window
  default_mappings = false, -- Bind default mappings
  debug = false, -- Print debug information
  opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent.
  resizing_mappings = false, -- Binds arrow keys to resizing the floating window.

  -- Hooks
  post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook.
  post_close_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook.

  -- References UI Configuration
  references = {
    provider = "telescope", -- telescope|fzf_lua|snacks|mini_pick|default
    telescope = require("telescope.themes").get_dropdown({ hide_preview = false })
  },

  -- Focus behavior
  focus_on_open = true, -- Focus the floating window when opening it.
  dismiss_on_move = false, -- Dismiss the floating window when moving the cursor.
  force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close
  bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden

  -- Window Stacking
  stack_floating_preview_windows = true, -- Whether to nest floating windows
  same_file_float_preview = true, -- Whether to open a new floating window for a reference within the current file

  -- Window Titles
  preview_window_title = { enable = true, position = "left" }, -- Whether to set the preview window title as the filename

  zindex = 1, -- Starting zindex for the stack of floating windows
  vim_ui_input = false, -- Whether to override vim.ui.input with a goto-preview floating window
}

Option Details

lsp_configs

This option allows customization of how LSP results are processed. By default, the plugin handles standard LSP responses. You can override get_config to transform arbitrary data.

lsp_configs = {
  get_config = function(data)
    -- data: The first result from the LSP response
    local uri = data.targetUri or data.uri
    local range = data.targetRange or data.range
    return uri, { range.start.line + 1, range.start.character }
  end
}

references

Controls which UI provider is used when multiple references are found. See the Features > Reference Providers page for more details.

vim_ui_input

If set to true, goto-preview will hijack the native vim.ui.input function. This replaces the command-line input area with a floating window input box for things like renaming variables.