{"id":13409296,"url":"https://github.com/rmagatti/goto-preview","last_synced_at":"2025-04-12T13:34:52.093Z","repository":{"id":38427565,"uuid":"374548714","full_name":"rmagatti/goto-preview","owner":"rmagatti","description":"A small Neovim plugin for previewing definitions using floating windows.","archived":false,"fork":false,"pushed_at":"2024-06-27T07:04:39.000Z","size":128,"stargazers_count":791,"open_issues_count":10,"forks_count":27,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-31T20:36:01.414Z","etag":null,"topics":["hacktoberfest","lua","neovim","neovim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rmagatti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-07T05:46:09.000Z","updated_at":"2024-07-31T15:04:24.000Z","dependencies_parsed_at":"2023-11-21T07:49:46.171Z","dependency_job_id":"57dfaf67-2532-4a9a-ab1b-336f9dd595f0","html_url":"https://github.com/rmagatti/goto-preview","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmagatti%2Fgoto-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmagatti%2Fgoto-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmagatti%2Fgoto-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmagatti%2Fgoto-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmagatti","download_url":"https://codeload.github.com/rmagatti/goto-preview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573679,"owners_count":21126882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","lua","neovim","neovim-plugin"],"created_at":"2024-07-30T20:00:59.696Z","updated_at":"2025-04-12T13:34:52.074Z","avatar_url":"https://github.com/rmagatti.png","language":"Lua","funding_links":[],"categories":["LSP","Lua"],"sub_categories":["(requires Neovim 0.5)"],"readme":"## ⭐ Goto Preview\nA small Neovim plugin for previewing native LSP's goto definition, type definition, implementation, declaration and references calls in floating windows.\n\n### 🚀 Showcase\n\u003cimg src=\"https://github.com/rmagatti/readme-assets/blob/main/goto-preview-zoomed.gif\" /\u003e\n\n#### 🔗 References\n\u003cimg src=\"https://github.com/rmagatti/readme-assets/blob/main/goto-preview-references.gif\" /\u003e\n\n#### ⌨️ vim.ui.input\n\u003cimg src=\"https://github.com/rmagatti/readme-assets/blob/main/vim-ui-input-fullres.gif\" /\u003e\n\n### ⚠️ IMPORTANT NOTE\nMake sure you use Neovim \u003e `0.5.1` or GUIs like [Goneovim](https://github.com/akiyosi/goneovim), [Uivonim](https://github.com/smolck/uivonim) or [Neovide](https://github.com/neovide/neovide).\n\nThere is a bug in [Neovim `0.5`](https://github.com/neovim/neovim/issues/14735) that prevents the correct positioning of more than one preview window.\n\n### 📦 Installation\n[Lazy.nvim](https://github.com/folke/lazy.nvim)\n```lua\n{\n  \"rmagatti/goto-preview\",\n  dependencies = { \"rmagatti/logger.nvim\" },\n  event = \"BufEnter\",\n  config = true, -- necessary as per https://github.com/rmagatti/goto-preview/issues/88\n}\n```\n\nAfter installation it is recommended you run `:checkhealth goto-preview` to check if everything is in order.\nNote: the plugin has to be loaded for the checkhealth to run.\n\n### ⚙️ Configuration\n\n**Default**\n```lua\nrequire('goto-preview').setup {\n  width = 120, -- Width of the floating window\n  height = 15, -- Height of the floating window\n  border = {\"↖\", \"─\" ,\"┐\", \"│\", \"┘\", \"─\", \"└\", \"│\"}, -- Border characters of the floating window\n  default_mappings = false, -- Bind default mappings\n  debug = false, -- Print debug information\n  opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent.\n  resizing_mappings = false, -- Binds arrow keys to resizing the floating window.\n  post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook.\n  post_close_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook.\n  references = { -- Configure the telescope UI for slowing the references cycling window.\n    provider = \"telescope\", -- telescope|fzf_lua|snacks|mini_pick|default\n    telescope = require(\"telescope.themes\").get_dropdown({ hide_preview = false })\n  },\n  -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off \"peak\" functionality.\n  focus_on_open = true, -- Focus the floating window when opening it.\n  dismiss_on_move = false, -- Dismiss the floating window when moving the cursor.\n  force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close\n  bufhidden = \"wipe\", -- the bufhidden option to set on the floating window. See :h bufhidden\n  stack_floating_preview_windows = true, -- Whether to nest floating windows\n  same_file_float_preview = true, -- Whether to open a new floating window for a reference within the current file\n  preview_window_title = { enable = true, position = \"left\" }, -- Whether to set the preview window title as the filename\n  zindex = 1, -- Starting zindex for the stack of floating windows\n  vim_ui_input = true, -- Whether to override vim.ui.input with a goto-preview floating window\n \n}\n```\n\nThe `post_open_hook` function gets called right before setting the cursor position in the new floating window.\nOne can use this to set custom key bindings or really anything else they want to do when a new preview window opens.\n\nThe `post_close_hook` function gets called right before closing the preview window. This can be used to undo any\ncustom key bindings when you leave the preview window.\n\n### ⌨️ Mappings\nThere are no mappings by default, you can set `default_mappings = true` in the config to make use of the mappings I use or define your own.\n\n**Default**\n```viml\nnnoremap gpd \u003ccmd\u003elua require('goto-preview').goto_preview_definition()\u003cCR\u003e\nnnoremap gpt \u003ccmd\u003elua require('goto-preview').goto_preview_type_definition()\u003cCR\u003e\nnnoremap gpi \u003ccmd\u003elua require('goto-preview').goto_preview_implementation()\u003cCR\u003e\nnnoremap gpD \u003ccmd\u003elua require('goto-preview').goto_preview_declaration()\u003cCR\u003e\nnnoremap gP \u003ccmd\u003elua require('goto-preview').close_all_win()\u003cCR\u003e\nnnoremap gpr \u003ccmd\u003elua require('goto-preview').goto_preview_references()\u003cCR\u003e\n```\n\n**Custom example**\n```lua\nvim.keymap.set(\"n\", \"gp\", \"\u003ccmd\u003elua require('goto-preview').goto_preview_definition()\u003cCR\u003e\", {noremap=true})\n```\n\n### 📚 Custom Options\n\nThe `close_all_win` function takes an optional table as an argument.\n\nExample usage:\n```lua\nrequire(\"goto-preview\").close_all_win { skip_curr_window = true }\n```\n\n### Window manipulation\nOne can manipulate floating windows with the regular Vim window moving commands. See `:h window-moving`.\nExample:\n\u003cimg src=\"https://user-images.githubusercontent.com/2881382/121652080-88716e00-ca58-11eb-811c-677ec61d8e25.gif\" /\u003e\n\n### Supported languages\nGoto Preview should work with LSP responses for most languages now! If something doesn't work as expected, drop an issue and I'll be happy to check it out!\n\n**Note:** different language servers have potentially different shapes for the result of the `textDocument/definition`, `textDocument/typeDefinition`, `textDocument/implementation` and `textDocument/declaration` calls.\nUntil more are added one can pass in custom responses through the `lsp_configs` config value. Just follow the same pattern returning two values, a `target (string)` and a `cursor_position ({line_num, col_num})`. The `data` parameter is the `[1]` of the LSP's `result` of the definition/implementation calls and is what gets passed into the custom `get_config` function.\n\n\n### Tested with\n```\nNVIM v0.11.0-dev-5068+g7371abf755-Homebrew\nBuild type: Release\nLuaJIT 2.1.1736781742\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmagatti%2Fgoto-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmagatti%2Fgoto-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmagatti%2Fgoto-preview/lists"}