Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Fildo7525/pretty_hover
A small and customizable neovim plugin for pretty printing the hover information from LSP servers
https://github.com/Fildo7525/pretty_hover
Last synced: 2 months ago
JSON representation
A small and customizable neovim plugin for pretty printing the hover information from LSP servers
- Host: GitHub
- URL: https://github.com/Fildo7525/pretty_hover
- Owner: Fildo7525
- License: mit
- Created: 2023-04-09T10:06:16.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-22T13:10:12.000Z (8 months ago)
- Last Synced: 2024-05-22T14:05:04.088Z (8 months ago)
- Language: Lua
- Homepage:
- Size: 175 KB
- Stars: 129
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- my-neovim-pluginlist - Fildo7525/pretty_hover - commit/Fildo7525/pretty_hover) ![](https://img.shields.io/github/commit-activity/y/Fildo7525/pretty_hover) (New features / Popup Info)
README
pretty_hover## Table of contents
- [How it looks](#how-it-looks)
- [Installation and setup](#installation-and-setup)
- [Configuration](#configuration)
- [Default config](#default-configuration)
- [Limitations](#limitations)
- [Contributing](#contributing)
- [Inspiration](#inspiration)Pretty_hover is a lightweight plugin that parses the hover message before opening the popup window.
The output can be easily manipulated with. This will result in a more readable hover message.An additional feature is `number conversion`. If you are tired of constantly converting some numbers to hex, octal
or binary you can use this plugin to do it for you.### How it looks
> _**NOTE**_: The colors of the text depend on the color of your chosen colorscheme.
These pictures are taken with colorscheme `catppuccin-mocha`Using native vim.lsp.buf.hover()
Using pretty_hover
## Installation and setup
### via Lazy
```lua
{
"Fildo7525/pretty_hover",
event = "LspAttach",
opts = {}
},
```### via Packer
```lua
use {
"Fildo7525/pretty_hover",
config = function()
require("pretty_hover").setup({})
end
}
```### Using Pretty Hover
To open a hover window, run the following lua snippet (or bind it to a key)
```lua
require("pretty_hover").hover()
```To close a hover window either move the cursor as with nvim's hover popup or
run the following lua snippet (e.g. from a keymap)
```lua
require("pretty_hover").close()
```
**NOTE: When focused on a hover window, you can also press `q` to close the hover window**### Configuration
| Parameter | Description |
|----------------- | -------------- |
| line | If one of the supplied strings is located as the first word in the line the whole line is surrounded by `stylers.line`. |
| listing | These words will be substituted with `stylers.listing`. |
| word | List of strings. If this word is detected at the beginning of a line the next word is surrounded by `styles.word` |
| header | List of strings. If this word is detected at the beginning of a line the word is substituted by `styles.header` |
| return statement | This words are substituted with **Return** (in bold) |
| references | If any word from this list is detected, the next word is surrounded by `styles.references[1]`. If this word is located in `line` section the next word is surrounded by `stylers.references[2]` (see [Limitations](#limitations)) |
| hl | 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. |
| border | Sets the border of the hover window. (none|single|double|rounded|solid|shadow). |
| max_width | Sets the maximum width of the window. If you don't want any limitation set to nil. |
| max_height | Sets the maximum height of the window. If you don't want any limitation set to nil. |
| toggle | Flag detecting whether you want to have the hover just as a toggle window or make the popup focusable. |
| detect_hyperlinks | Flag detecting whether you want to detect hyperlinks in the hover window. This feature is experimental and can be disabled by setting the flag to false. |> _**NOTE**_: To really use this plugin you have to create a keymap that calls `require('pretty_hover').hover()` function.
The plugin supports code blocks. By specifying `@code{cpp}` the text in the popup window is highlighted with its filetype highlighter
until the `@endcode` is hit. When the filetype is not specified in the flag `@code` the filetype from the currently opened file is used.#### Default configuration
```lua
{
-- Tables grouping the detected strings and using the markdown highlighters.
header = {
detect = { "[\\@]class" },
styler = '###',
},
line = {
detect = { "[\\@]brief" },
styler = '**',
},
listing = {
detect = { "[\\@]li" },
styler = " - ",
},
references = {
detect = { "[\\@]ref", "[\\@]c", "[\\@]name" },
styler = { "**", "`" },
},
word = {
detect = { "[\\@]param", "[\\@]tparam", "[\\@]see", "[\\@]*param*" },
styler = "`",
},-- Tables used for cleaner identification of hover segments.
code = {
start = { "[\\@]code" },
ending = { "[\\@]endcode" },
},
return_statement = {
"[\\@]return",
"[\\@]*return*",
},-- Highlight groups used in the hover method. Feel free to define your own highlight group.
hl = {
error = {
color = "#DC2626",
detect = { "[\\@]error", "[\\@]bug" },
line = false, -- Flag detecting if the whole line should be highlighted
},
warning = {
color = "#FBBF24",
detect = { "[\\@]warning", "[\\@]thread_safety", "[\\@]throw" },
line = false,
},
info = {
color = "#2563EB",
detect = { "[\\@]remark", "[\\@]note", "[\\@]notes" },
},
-- Here you can set up your highlight groups.
},border = "rounded",
max_width = nil,
max_height = nil,
toggle = false,-- Flag detecting whether you want to detect hyperlinks in the hover window.
-- This feature is experimental and can be disabled by setting the flag to false.
detect_hyperlinks = true,
}
```### Limitations
Currently, neovim supports these markdown stylers: \`, \*, \`\`\`[language]. Unfortunately, you cannot do any
of their combination. If the support is extended there will be more options to style the pop-up window.
Newly this plugin started supporting highlighting see the [Configuration](#configuration) for more information.### Contributing
If you have any idea how to improve this plugin do not hesitate to create a PR. Otherwise, if you know how
to improve the plugin mention it in a new issue. Enjoy the plugin.### Inspiration
https://github.com/lewis6991/hover.nvim