{"id":13476520,"url":"https://github.com/Fildo7525/pretty_hover","last_synced_at":"2025-03-27T03:30:26.659Z","repository":{"id":152286236,"uuid":"625502036","full_name":"Fildo7525/pretty_hover","owner":"Fildo7525","description":"A small and customizable neovim plugin for pretty printing the hover information from LSP servers","archived":false,"fork":false,"pushed_at":"2024-05-22T13:10:12.000Z","size":179,"stargazers_count":129,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-22T14:05:04.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fildo7525.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-04-09T10:06:16.000Z","updated_at":"2024-07-31T12:30:06.982Z","dependencies_parsed_at":null,"dependency_job_id":"99396385-aaf6-4e5d-a3f8-9f288de7739c","html_url":"https://github.com/Fildo7525/pretty_hover","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fildo7525%2Fpretty_hover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fildo7525%2Fpretty_hover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fildo7525%2Fpretty_hover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fildo7525%2Fpretty_hover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fildo7525","download_url":"https://codeload.github.com/Fildo7525/pretty_hover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245778222,"owners_count":20670682,"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":[],"created_at":"2024-07-31T16:01:31.383Z","updated_at":"2025-03-27T03:30:26.646Z","avatar_url":"https://github.com/Fildo7525.png","language":"Lua","funding_links":[],"categories":["Lua","Recently Updated","LSP","New features"],"sub_categories":["[Apr 09, 2025](/content/2025/04/09/README.md)","(requires Neovim 0.5)","Popup Info"],"readme":"\u003ch1 align=\"center\"\u003e\npretty_hover\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/Fildo7525/pretty_hover/stargazers\"\u003e\n\t\u003cimg\n\t\talt=\"Stargazers\"\n\t\tsrc=\"https://img.shields.io/github/stars/Fildo7525/pretty_hover?style=for-the-badge\u0026logo=starship\u0026color=fae3b0\u0026logoColor=d9e0ee\u0026labelColor=282a36\"\n\t/\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/Fildo7525/pretty_hover/issues\"\u003e\n\t\u003cimg\n\t\talt=\"Issues\"\n\t\tsrc=\"https://img.shields.io/github/issues/Fildo7525/pretty_hover?style=for-the-badge\u0026logo=gitbook\u0026color=ddb6f2\u0026logoColor=d9e0ee\u0026labelColor=282a36\"\n\t/\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/Fildo7525/pretty_hover/contributors\"\u003e\n\t\u003cimg\n\t\talt=\"Contributors\"\n\t\tsrc=\"https://img.shields.io/github/contributors/Fildo7525/pretty_hover?style=for-the-badge\u0026logo=opensourceinitiative\u0026color=abe9b3\u0026logoColor=d9e0ee\u0026labelColor=282a36\"\n\t/\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n## Table of contents\n\n - [How it looks](#how-it-looks)\n - [Installation and setup](#installation-and-setup)\n - [Configuration](#configuration)\n - [Integration](#integration)\n\t- [Blink.cmp](#blink.cmp)\n - [Default config](#default-configuration)\n - [Limitations](#limitations)\n - [Contributing](#contributing)\n - [Inspiration](#inspiration)\n\nPretty_hover is a lightweight plugin that parses the hover message before opening the popup window.\nThe output can be easily manipulated with. This will result in a more readable hover message.\n\nAn additional feature is `number conversion`. If you are tired of constantly converting some numbers to hex, octal\nor binary you can use this plugin to do it for you.\n\n### How it looks\n\n\u003e _**NOTE**_: The colors of the text depend on the color of your chosen colorscheme.\nThese pictures are taken with colorscheme `catppuccin-mocha`\n\nUsing native vim.lsp.buf.hover()\n\u003cimg src=\"https://github.com/user-attachments/assets/5f4bd780-8a24-44c8-8a8e-4803ae9f7ace\"\u003e\n\nUsing pretty_hover\n\u003cimg src=\"https://github.com/user-attachments/assets/e547359e-0a82-4fac-ba75-388cdd291804\"\u003e\n\n## Installation and setup\n\n### via Lazy\n```lua\n{\n\t\"Fildo7525/pretty_hover\",\n\tevent = \"LspAttach\",\n\topts = {}\n},\n```\n\n### via Packer\n```lua\nuse {\n\t\"Fildo7525/pretty_hover\",\n\tconfig = function()\n\t\trequire(\"pretty_hover\").setup({})\n\tend\n}\n```\n\n### Using Pretty Hover\nTo open a hover window, run the following lua snippet (or bind it to a key)\n```lua\nrequire(\"pretty_hover\").hover()\n```\n\nTo close a hover window either move the cursor as with nvim's hover popup or\nrun the following lua snippet (e.g. from a keymap)\n```lua\nrequire(\"pretty_hover\").close()\n```\n**NOTE: When focused on a hover window, you can also press `q` to close the hover window**\n\n### Configuration\n\n| Parameter\t\t| Description\t|\n|----------------- | -------------- |\n| line\t\t\t | If one of the supplied strings is located as the first word in the line the whole line is surrounded by `line.styler`. |\n| listing\t\t  | These words will be substituted with `listing.styler`. |\n| group\t\t\t | Table containing group name and its detectors. If this word is detected at the beginning of a line the next word is surrounded by `group.styler`. The whole group is separated by an line and the first line containing es the group name. |\n| header\t\t   | List of strings. If this word is detected at the beginning of a line the word is substituted by `header.styler` |\n| return statement | This words are substituted with **Return** (in bold) |\n| references\t   | If any word from this list is detected, the next word is surrounded by `references.styler[1]`. If this word is located in `line` section the next word is surrounded by `references.styler[2]` (see [Limitations](#limitations)) |\n| hl\t\t\t   | This is a table of highlighting groups. You can define new groups by specifying at least two parameters. `color` and `detect`. Flag `line` is not mandatory, however by setting this flag you can ensure that the whole line is highlighted. When a detector from the table `detect` is found the detector is made uppercase, omits the beginning tag and gets highlighted. |\n| border\t\t   | Sets the border of the hover window. (none \\| single \\| double \\| rounded \\| solid \\| shadow). |\n| wrap\t\t\t| Flag whether to wrap the text if the window is smaller. Otherwise the floating window is scrollable horizontally |\n| max_width\t\t| Sets the maximum width of the window. If you don't want any limitation set to nil. |\n| max_height\t   | Sets the maximum height of the window. If you don't want any limitation set to nil. |\n| toggle\t   | Flag detecting whether you want to have the hover just as a toggle window or make the popup focusable. |\n\n\u003e _**NOTE**_: To really use this plugin you have to create a keymap that calls `require('pretty_hover').hover()` function.\n\nThe plugin supports code blocks. By specifying `@code{cpp}` the text in the popup window is highlighted with its filetype highlighter\nuntil the `@endcode` is hit. When the filetype is not specified in the flag `@code` the filetype from the currently opened file is used.\n\n#### Default configuration\n\n```lua\n{\n\t-- Tables grouping the detected strings and using the markdown highlighters.\n\theader = {\n\t\tdetect = { \"[\\\\@]class\" },\n\t\tstyler = '###',\n\t},\n\tline = {\n\t\tdetect = { \"[\\\\@]brief\" },\n\t\tstyler = '**',\n\t},\n\tlisting = {\n\t\tdetect = { \"[\\\\@]li\" },\n\t\tstyler = \" - \",\n\t},\n\treferences = {\n\t\tdetect = { \"[\\\\@]ref\", \"[\\\\@]c\", \"[\\\\@]name\" },\n\t\tstyler = { \"**\", \"`\" },\n\t},\n\tgroup = {\n\t\tdetect = {\n\t\t\t-- [\"Group name\"] = {\"detectors\"}\n\t\t\t[\"Parameters\"] = { \"[\\\\@]param\", \"[\\\\@]*param*\" },\n\t\t\t[\"Types\"] = { \"[\\\\@]tparam\" },\n\t\t\t[\"See\"] = { \"[\\\\@]see\" },\n\t\t\t[\"Return Value\"] = { \"[\\\\@]retval\" },\n\t\t},\n\t\tstyler = \"`\",\n\t},\n\n\t-- Tables used for cleaner identification of hover segments.\n\tcode = {\n\t\tstart = { \"[\\\\@]code\" },\n\t\tending = { \"[\\\\@]endcode\" },\n\t},\n\treturn_statement = {\n\t\t\"[\\\\@]return\",\n\t\t\"[\\\\@]*return*\",\n\t},\n\n\t-- Highlight groups used in the hover method. Feel free to define your own highlight group.\n\thl = {\n\t\terror = {\n\t\t\tcolor = \"#DC2626\",\n\t\t\tdetect = { \"[\\\\@]error\", \"[\\\\@]bug\" },\n\t\t\tline = false, -- Flag detecting if the whole line should be highlighted\n\t\t},\n\t\twarning = {\n\t\t\tcolor = \"#FBBF24\",\n\t\t\tdetect = { \"[\\\\@]warning\", \"[\\\\@]thread_safety\", \"[\\\\@]throw\" },\n\t\t\tline = false,\n\t\t},\n\t\tinfo = {\n\t\t\tcolor = \"#2563EB\",\n\t\t\tdetect = { \"[\\\\@]remark\", \"[\\\\@]note\", \"[\\\\@]notes\" },\n\t\t},\n\t\t-- Here you can set up your highlight groups.\n\t},\n\n\tborder = \"rounded\",\n\twrap = true,\n\tmax_width = nil,\n\tmax_height = nil,\n\ttoggle = false,\n}\n```\n\n### Integration\n\nThe plugin supports an easy integration:\n\n```lua\nlocal parsed = require(\"pretty_hover.parser\").parse(text)\n```\n\nthe parsed variable contains two fields `text` and `highlight`. The `text` field contains the converted text to markdown\nand the `highlight` field contains the highlight groups for the text.\n\nYou can use the `parsed` variable to display the hover message in your own way.\n\n```lua\nvim.lsp.util.open_floating_preview(parsed.text, \"markdown\", {\n\tfocus = true,\n\tfocusable = true,\n\twrap = true,\n\twrap_at = 100,\n\tmax_width = 100,\n\tborder = \"rounded\",\n\tfocus_id = \"pretty-hover-example\",\n})\n```\n\nTo see an example of the implementation see the `pretty_hover/examples/parsing.lua` file.\n\n#### Blink.cmp\n\nThis functionality is supported for blink.cmp from version v0.13.0 and higher.\nTo use this plugin with `blink.cmp` documentation you can add the following code snippet to you configuration:\n\n```lua\n{\n\tcompletion = {\n\t\tdocumentation = {\n\t\t\tdraw = function(opts)\n\t\t\t\tif opts.item and opts.item.documentation then\n\t\t\t\t\tlocal out = require(\"pretty_hover.parser\").parse(opts.item.documentation.value)\n\t\t\t\t\topts.item.documentation.value = out:string()\n\t\t\t\tend\n\n\t\t\t\topts.default_implementation(opts)\n\t\t\tend,\n\t\t}\n\t},\n}\n```\n\n### Limitations\n\nCurrently, neovim supports these markdown stylers: \\`, \\*, \\`\\`\\`[language]. Unfortunately, you cannot do any\nof their combination. If the support is extended there will be more options to style the pop-up window.\nNewly this plugin started supporting highlighting see the [Configuration](#configuration) for more information.\n\n### Contributing\n\nIf you have any idea how to improve this plugin do not hesitate to create a PR. Otherwise, if you know how\nto improve the plugin mention it in a new issue. Enjoy the plugin.\n\n### Inspiration\n\nhttps://github.com/lewis6991/hover.nvim\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFildo7525%2Fpretty_hover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFildo7525%2Fpretty_hover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFildo7525%2Fpretty_hover/lists"}