### Keybindings and Mouse Support Setup for Hover.nvim Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Example configuration for setting up recommended keybindings and enabling mouse support for Hover.nvim interactions. ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', }, preview_opts = { border = 'single' }, preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp' }, mouse_delay = 1000, }) -- Setup keymaps vim.keymap.set('n', 'K', function() require('hover').open() end, { desc = 'Hover (next provider)' }) vim.keymap.set('n', 'gK', function() require('hover').enter() end, { desc = 'Hover (enter/focus)' }) vim.keymap.set('n', '', function() require('hover').switch('previous') end, { desc = 'Hover (previous provider)' }) vim.keymap.set('n', '', function() require('hover').switch('next') end, { desc = 'Hover (next provider)' }) -- Mouse support vim.o.mousemoveevent = true vim.keymap.set('n', '', function() require('hover').mouse() end, { desc = 'Hover (mouse)' }) ``` -------------------------------- ### Hover.nvim Configuration and Keybindings Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Example configuration for hover.nvim, specifying providers, preview window options, and mouse interaction settings. Includes setup for common keybindings. ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', }, preview_opts = { border = 'single', max_width = 80, max_height = 30, }, preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp' }, mouse_delay = 1000, }) -- Setup keybindings vim.keymap.set('n', 'K', function() require('hover').open() end) vim.keymap.set('n', 'gK', function() require('hover').enter() end) vim.keymap.set('n', '', function() require('hover').switch('previous') end) vim.keymap.set('n', '', function() require('hover').switch('next') end) vim.o.mousemoveevent = true vim.keymap.set('n', '', function() require('hover').mouse() end) ``` -------------------------------- ### Complete Hover.nvim Configuration Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md A comprehensive example demonstrating the configuration of various Hover.nvim features, including providers, mouse behavior, window appearance, and development settings. ```lua require('hover').config({ -- Core providers providers = { { module = 'hover.providers.diagnostic', priority = 2000, name = 'Diags', }, 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', -- Optional providers 'hover.providers.gh', 'hover.providers.gh_user', 'hover.providers.jira', 'hover.providers.fold_preview', }, -- Mouse behavior mouse_providers = { 'hover.providers.lsp', 'hover.providers.diagnostic', }, mouse_delay = 500, -- Window appearance preview_opts = { border = 'rounded', max_width = 100, max_height = 40, }, preview_window = false, title = true, -- Development dev_mode = false, init = function() -- Custom initialization end, }) ``` -------------------------------- ### Open Floating Preview Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md A complete example demonstrating how to use `util.open_floating_preview` to display markdown content with custom styling, including border and max dimensions. ```lua local util = require('hover.util') return { name = 'Custom', execute = function(params, done) local lines = { '# Title', '', 'Some content here', } local winid = util.open_floating_preview(lines, nil, 'markdown', { border = 'rounded', max_width = 80, max_height = 20, }) done({ lines = lines, filetype = 'markdown' }) end } ``` -------------------------------- ### Example: Providing String Content Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Demonstrates how to return string content with a specified filetype for display. ```lua -- String content with syntax highlighting done({ lines = { '#!/bin/bash', 'echo "hello"' }, filetype = 'bash' }) ``` -------------------------------- ### Example: Providing a Pre-populated Buffer Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Illustrates how to use a pre-populated buffer as the hover result. ```lua -- Pre-populated buffer done({ bufnr = buffer_id }) ``` -------------------------------- ### Example Built-in Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Lists a built-in provider for hover.nvim. All providers are documented with examples. ```Lua LSP (priority 1000) ``` -------------------------------- ### Example: Providing Markdown Content Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Shows how to return markdown-formatted lines for display. ```lua -- Markdown with formatting done({ lines = { '# Title', '', 'Paragraph' }, filetype = 'markdown' }) ``` -------------------------------- ### Minimal Hover.nvim Setup Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md Configure hover.nvim with default settings. This is the simplest way to enable the plugin. ```lua require('hover').config({}) -- Uses all defaults ``` -------------------------------- ### Highlight Setup Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Functions and constants for setting up and customizing highlight groups used within hover.nvim. ```APIDOC ## Highlights (hover.highlights) ### Description Manages highlight groups for styling the hover window. ### Functions - `highlights.setup()`: Sets up the default highlight groups. ### Constants - `highlights.HIGHLIGHT_GROUP_DEFAULTS`: Default highlight group configurations. ``` -------------------------------- ### Hover.Config.Provider Example Usage Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Demonstrates how to configure a custom provider by specifying its module, name, and priority within the Hover.nvim configuration. ```lua require('hover').config({ providers = { { module = 'hover.providers.lsp', name = 'Type Info', priority = 2000 } } }) ``` -------------------------------- ### Example Module Reference Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Indicates a module within the hover.nvim project. The documentation covers six core modules. ```Lua hover.actions ``` -------------------------------- ### Custom Provider Module Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Example of a custom provider module that returns information about the word under the cursor. This module can be registered passively by placing it in your plugin's runtimepath and referencing it in hover.config. ```lua -- myplugin/hover_provider.lua return { name = 'My Provider', priority = 500, enabled = function(bufnr, opts) return true end, execute = function(params, done) local word = vim.fn.expand('') done({ lines = { 'Word: ' .. word }, filetype = 'markdown' }) end } ``` -------------------------------- ### Configuration Merging Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Illustrates how user configuration is merged with defaults using `vim.tbl_deep_extend('force')`, showing that the 'providers' key results in a full table replacement. ```lua -- Default { providers = { 'a', 'b', 'c' }, title = true } -- User config { providers = { 'x' } } -- Result (full replacement, not append) { providers = { 'x' }, title = true } ``` -------------------------------- ### Custom Highlight Group Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md Demonstrates how to set custom highlight groups for the hover window elements. ```lua vim.api.nvim_set_hl(0, 'HoverWindow', { bg = '#1e1e1e' }) vim.api.nvim_set_hl(0, 'HoverBorder', { fg = '#888888' }) ``` -------------------------------- ### Configure Hover Providers Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Configure which hover providers to enable. This example includes diagnostic, LSP, and DAP providers. ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', } }) ``` -------------------------------- ### Standard Hover.nvim Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md A comprehensive setup for hover.nvim including common providers, preview window options, and mouse hover settings. ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', }, preview_opts = { border = 'single' }, preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp', }, mouse_delay = 1000 }) ``` -------------------------------- ### Example Rendering of Provider Tabs Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/highlights.md Illustrates how the provider tabs appear with active, separator, and inactive states. ```text | LSP | Diagnostics | ← Provider tabs ^ ^ ^ Active / Separator / Inactive ``` -------------------------------- ### Apply Hover.nvim Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Call this function once during plugin setup to apply user configurations. It takes a table of options. ```lua require('hover').config(user_config) ``` -------------------------------- ### Example Type Definition Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Shows a type definition used within hover.nvim. All types are documented with field definitions. ```Lua Hover.Options ``` -------------------------------- ### Example Function Signature Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Illustrates the signature of a function within the hover.nvim API. These are documented with full signatures. ```Lua hover.open() ``` -------------------------------- ### Example: Hiding a Provider Result Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Demonstrates how to signal that no hover result should be displayed. ```lua -- No result (hide provider) done(false) done(nil) ``` -------------------------------- ### Define a Simple Hover Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/README.md Example of a basic Hover.Provider implementation in Lua. This provider is always enabled and returns a simple test message. ```lua return { name = 'Simple', priority = 1000, --- @param bufnr integer enabled = function(bufnr) return true end, --- @param params Hover.Provider.Params --- @param done fun(result?: false|Hover.Result) execute = function(params, done) done{lines={'TEST'}, filetype="markdown"} end } ``` -------------------------------- ### Hover Window Creation Lifecycle Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Outlines the sequence of calls involved in creating a hover window, starting from `hover.open()` and proceeding through provider execution and display. ```lua hover.open() → get_enabled_providers() → run_provider() → provider.execute(params, done) → await done callback → show_hover() → util.open_floating_preview() → make_title() → add_title() → set window variables ``` -------------------------------- ### Example Highlight Group Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Demonstrates a highlight group used for customizing the hover window's appearance. All highlight groups are documented. ```Lua HoverWindow ``` -------------------------------- ### Hover.nvim Provider Registration Flow Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Illustrates the sequence of calls involved in initializing and registering providers within hover.nvim, starting from configuration loading. ```text hover.config() → hover.providers.init(config_providers) → load_provider() for each config entry → require(module_name) → add_provider_or_group() → (register in priority order) ``` -------------------------------- ### Markdown Processing Example Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md Demonstrates the effect of markdown processing, including blank line collapsing and separator replacement, on a sample content array. ```lua local contents = { '# Title', '', '', 'Paragraph 1', '---', 'Paragraph 2', } -- After processing: -- # Title -- -- Paragraph 1 -- ──────────── -- Paragraph 2 ``` -------------------------------- ### Prefix Format: String Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md Use a plain string as a prefix for each diagnostic message line. Example shows adding '→ '. ```lua prefix = '→ ' -- Result: "→ Error message" ``` -------------------------------- ### Example Hover Provider Registration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Register a custom hover provider with a name, priority, and an execute function. The enabled function can conditionally disable the provider. ```lua return { name = 'My Hover', priority = 500, enabled = function(bufnr, opts) return vim.bo[bufnr].filetype == 'lua' end, execute = function(params, done) done({ lines = { 'Hover content' }, filetype = 'markdown' }) end } ``` -------------------------------- ### Example Provider Group Registration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Register multiple related providers as a group with an optional group-level priority. This is useful for organizing providers, such as LSP clients. ```lua return { priority = 1000, providers = { { name = 'Client1', execute = function(params, done) ... end }, { name = 'Client2', execute = function(params, done) ... end } } } ``` -------------------------------- ### Select Hover Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference.md Prompts the user to select a hover provider from available options and displays its content. No specific setup is required beyond calling the function. ```lua require('hover').select() ``` -------------------------------- ### Get Enabled Providers Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Filters registered providers based on context and configuration options. It checks provider availability and returns them in priority order. ```lua local function get_providers(bufnr: integer, opts: Hover.Options) -> Hover.Provider.Resolved[] end ``` -------------------------------- ### Initialize and Open Hover Window Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Initialize hover.nvim with configuration options and open the hover window. Keybindings for opening, entering, switching, and closing the hover window are also shown. ```lua require('hover').config(opts) -- Initialize with config require('hover').open(opts) -- Show hover window require('hover').select(opts) -- Prompt to select provider require('hover').switch(dir, opts) -- Cycle providers (next/previous) require('hover').enter() -- Focus hover window require('hover').mouse() -- Show on mouse move require('hover').close(bufnr) -- Close hover window ``` -------------------------------- ### highlights.setup() Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/highlights.md Initializes highlight groups with default links. This function iterates through default highlight group mappings and applies them if no custom definition exists, ensuring the hover UI elements have appropriate styling. ```APIDOC ## highlights.setup() ### Description Initializes highlight groups with default links. This function iterates through default highlight group mappings and applies them if no custom definition exists, ensuring the hover UI elements have appropriate styling. ### Method ```lua function M.setup() ``` ### Parameters This function does not accept any parameters. ### Returns - void: Configures highlight groups in the global namespace. ### Behavior 1. Iterates through HIGHLIGHT_GROUP_DEFAULTS. 2. Checks if a highlight group already has a custom definition. 3. If not defined, links to the default group. 4. Called automatically by `require('hover').config()`. ### Example ```lua require('hover.highlights').setup() ``` ``` -------------------------------- ### Basic Hover Keymap Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md Set up a basic keymap for the 'K' command to open the hover window. ```lua vim.keymap.set('n', 'K', function() require('hover').open() end) -- Shows diagnostics if available, falls back to other providers ``` -------------------------------- ### Initialize hover.nvim with Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference.md Use this function to initialize hover.nvim with your custom configuration. It registers providers and sets up highlights. ```lua function M.config(user_config: Hover.UserConfig) -- This function is not provided in the source, only its signature is shown. end ``` ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', }, preview_opts = { border = 'single' }, preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp', }, mouse_delay = 1000 }) ``` -------------------------------- ### hover.config Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference.md Initializes hover.nvim with user configuration, registering providers and setting up highlights. ```APIDOC ## hover.config(user_config) ### Description Initializes hover.nvim with user configuration, registering providers and setting up highlights. ### Method Function Call ### Parameters #### Arguments - **user_config** (Hover.UserConfig) - Required - Configuration object ### Request Example ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', }, preview_opts = { border = 'single' }, preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp', }, mouse_delay = 1000 }) ``` ### Response #### Success Response - **void** - Applies configuration and initializes highlights ``` -------------------------------- ### Configure Hover.nvim with a Custom Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/README.md Shows how to register a custom provider with the hover.nvim configuration. Ensure the provider path matches your file structure. ```lua require('hover').config({ providers = { 'myplugin.simple_provider' } }) ``` -------------------------------- ### Hover.nvim Execution Flow Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Details the step-by-step process from user interaction (pressing 'K') to displaying hover information, including asynchronous provider execution. ```text User presses K → hover.open(opts) → async.run(function) → get_providers() [filtered, enabled] → run_provider() → provider.execute(params, done) [async work] → async.await(provider.execute, ...) → async.scheduler() → show_hover() → util.open_floating_preview() ``` -------------------------------- ### Run Async Task with Await and Scheduler Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Demonstrates how to use the async module to run a task, await its result, and return to the main thread for UI operations. ```lua local async = require('hover.async') async.run(function() local result = async.await(2, vim.system, { 'curl', 'url' }) async.scheduler() -- Back to main thread -- UI operations here end) ``` -------------------------------- ### Configure Initialization Callback Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Set an optional callback function to be invoked once before the first hover action. Defaults to nil. ```lua config.init = nil -- Default: optional function ``` ```lua require('hover').config({ init = function() print('Hover.nvim initialized') -- Additional setup here end }) ``` -------------------------------- ### Define a Hover Provider Group Source: https://github.com/lewis6991/hover.nvim/blob/main/README.md Example of defining a Hover.ProviderGroup in Lua. This groups multiple providers under a single entry and allows for a group-level priority. ```lua local simple_provider = { name = 'Simple', --- @param bufnr integer enabled = function(bufnr) return true end, --- @param params Hover.Provider.Params --- @param done fun(result?: false|Hover.Result) execute = function(params, done) done{lines={'TEST'}, filetype="markdown"} end } return { priority = 1000, providers = { simple_provider } } ``` -------------------------------- ### Development Mode and Initialization Callback Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md Enable development mode for hover.nvim to see errors and define a custom initialization function that runs before the first hover action. ```lua require('hover').config({ dev_mode = true, -- Show errors instead of silently handling them init = function() print('Hover initialized') end }) ``` -------------------------------- ### actions.open Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Opens the hover window, cycling to the next available provider if one is already open. It handles initialization, provider selection, and displays the first enabled provider's result or cycles through them. ```APIDOC ## actions.open ### Description Opens the hover window. If a hover window is already open, it cycles to the next available provider. Otherwise, it displays the first enabled provider's result. ### Method ``` function M.open(opts?: Hover.actions.open.Options) ``` ### Parameters #### Options (`opts`) - **bufnr** (integer) - Optional - Target buffer (default: current buffer). - **pos** ([integer, integer]) - Optional - Position (default: current cursor position). - **relative** (string) - Optional - Window positioning (e.g., 'cursor', 'mouse'). - **providers** (string[]) - Optional - Filter to specific providers. ### Behavior - Initializes hover on the first call. - Gets a list of enabled providers. - Cycles to the next provider if a hover window is already open. - Displays the first enabled provider's result if no hover window is open. - Continues cycling through providers until one returns a result. ### Async This function is non-blocking and uses coroutines. ``` -------------------------------- ### Configure hover.nvim Providers and Keymaps Source: https://github.com/lewis6991/hover.nvim/blob/main/README.md Configure the list of providers to load, appearance options, and set keymaps for opening, navigating, and interacting with hover windows. Mouse support requires enabling `mousemoveevent`. ```lua require('hover').config({ --- List of modules names to load as providers. --- @type (string|Hover.Config.Provider)[] providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', -- Optional, disabled by default: -- 'hover.providers.gh', -- 'hover.providers.gh_user', -- 'hover.providers.jira', -- 'hover.providers.fold_preview', -- 'hover.providers.highlight', }, preview_opts = { border = 'single' }, -- Whether the contents of a currently open hover window should be moved -- to a :h preview-window when pressing the hover keymap. preview_window = false, title = true, mouse_providers = { 'hover.providers.lsp', }, mouse_delay = 1000 }) -- Setup keymaps vim.keymap.set('n', 'K', function() require('hover').open() end, { desc = 'hover.nvim (open)' }) vim.keymap.set('n', 'gK', function() require('hover').enter() end, { desc = 'hover.nvim (enter)' }) vim.keymap.set('n', '', function() require('hover').switch('previous') end, { desc = 'hover.nvim (previous source)' }) vim.keymap.set('n', '', function() require('hover').switch('next') end, { desc = 'hover.nvim (next source)' }) -- Mouse support vim.keymap.set('n', '', function() require('hover').mouse() end, { desc = 'hover.nvim (mouse)' }) vim.o.mousemoveevent = true ``` -------------------------------- ### Open Hover with Dictionary Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Set up a keymap to open the hover window. Hovering over a valid English word will display its definition. ```lua vim.keymap.set('n', 'K', function() require('hover').open() end) -- Hover over valid English word to see definition ``` -------------------------------- ### Hover.nvim Module Dependency Graph Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Visualizes the module dependencies within the hover.nvim plugin, showing the entry point and its direct and indirect dependencies. ```text hover.lua (entry point) ├─ hover.actions (window control) │ ├─ hover.providers (provider system) │ │ └─ (all provider modules) │ ├─ hover.util (floating window) │ ├─ hover.async (async utilities) │ └─ hover.config (configuration) ├─ hover.config (user config) └─ hover.highlights (UI styling) ``` -------------------------------- ### Get Diagnostic Options Based on Scope Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md A Lua function to determine diagnostic options (line number or position) based on the configured float scope ('line' or 'cursor'). Converts to 0-indexed for Neovim API. ```lua local function get_diag_opts(pos) local float_opts = get_float_opts() local scope = float_opts.scope or 'line' local opts = {} if scope == 'line' then opts.lnum = pos[1] - 1 -- Convert to 0-indexed elseif scope == 'cursor' then opts.pos = { pos[1] - 1, pos[2] } end return opts end ``` -------------------------------- ### providers.init Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Initializes providers from configuration. This function is called automatically when the first hover action is triggered. It loads provider modules, applies configuration overrides, and registers them in priority order. ```APIDOC ## providers.init(config_providers) ### Description Initializes providers from configuration. Called automatically when first hover action is triggered. ### Function Signature ```lua function M.init(config_providers: (string|Hover.Config.Provider)[]) ``` ### Parameters #### Path Parameters - **config_providers** (string | Hover.Config.Provider)[] - Required - Array of provider module names or configuration objects. ### Behavior - Loads each provider module via require() - Applies config overrides (name, priority) - Registers providers in priority order - Throws error if provider module fails to load or doesn't return valid table ### Example ```lua require('hover.providers').init({ 'hover.providers.lsp', { module = 'hover.providers.diagnostic', priority = 2000, name = 'Diags' } }) ``` ``` -------------------------------- ### Open Hover with Man Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Set up a keymap to open the hover window. In a C file, hovering over a function name will display its man page. ```lua -- In C file, hover over function name vim.keymap.set('n', 'K', function() require('hover').open() end) ``` -------------------------------- ### Configure Hover.nvim Highlight Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Configure Hover.nvim to use the highlight provider. Ensure this is added to your Hover.nvim configuration. ```lua require('hover').config({ providers = { 'hover.providers.highlight', } }) ``` -------------------------------- ### actions.select Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Shows a `vim.ui.select` prompt to allow the user to choose a provider, and then displays the selected provider's content. This is useful for interactively selecting which hover information to view. ```APIDOC ## actions.select(opts?) ### Description Shows a `vim.ui.select` prompt to allow the user to choose a provider, and then displays the selected provider's content. This is useful for interactively selecting which hover information to view. ### Method `function M.select(opts?: Hover.Options)` ### Parameters #### Path Parameters - **opts** (Hover.Options) - Optional - Position and filtering options for the hover window ### Example ```lua require('hover').select() -- Shows: -- > 1. LSP -- > 2. Diagnostics -- > 3. Man ``` ``` -------------------------------- ### Configure Hover.nvim Providers Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Specify which provider modules hover.nvim should load. Providers can be simple module names or objects with custom names and priorities. ```lua config.providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', } ``` ```lua { module = 'hover.providers.lsp', name = 'Type Info', priority = 2000 } ``` ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', { module = 'hover.providers.lsp', priority = 2000, name = 'LSP Info' }, 'hover.providers.dap', } }) ``` -------------------------------- ### Open Hover with DAP Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Set up a keymap to open the hover window. When a DAP session is active, it shows expression evaluation; otherwise, it falls back to LSP hover. ```lua -- During active debug session vim.keymap.set('n', 'K', function() require('hover').open() end) ``` -------------------------------- ### Select Hover Provider via UI Prompt Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Displays a `vim.ui.select` prompt allowing the user to choose a hover provider. Once selected, the chosen provider's content is displayed. Options can be provided to control positioning and filtering. ```lua function M.select(opts?: Hover.Options) ``` ```lua require('hover').select() ``` -------------------------------- ### Configure Development Mode Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Enable development mode to show errors in the UI instead of silently handling them. Defaults to false. ```lua config.dev_mode = false -- Default: boolean ``` ```lua require('hover').config({ dev_mode = true -- Show errors during development }) ``` -------------------------------- ### Hover Provider Result: Content Lines Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Return hover content as an array of lines with an optional filetype for syntax highlighting. ```lua -- Option 1: Return content lines done({ lines = { 'Line 1', 'Line 2' }, filetype = 'markdown' }) ``` -------------------------------- ### Initialize Providers Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Initializes providers from a configuration array. This function is called automatically when the first hover action is triggered. It accepts an array of provider module names or configuration objects. ```lua function M.init(config_providers: (string|Hover.Config.Provider)[]) ``` ```lua require('hover.providers').init({ 'hover.providers.lsp', { module = 'hover.providers.diagnostic', priority = 2000, name = 'Diags' } }) ``` -------------------------------- ### Bind Keymap to Open Hover with Highlight Info Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Set up a keymap to trigger the Hover.nvim `open` function, which will display highlight information at the current cursor position. This is useful for debugging highlight groups. ```lua -- Debug highlight groups at cursor vim.keymap.set('n', 'K', function() require('hover').open() end) ``` -------------------------------- ### Open Floating Preview Window Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md Creates and opens a floating window to display hover content. Supports displaying raw text lines or content from a pre-populated buffer. Options can be provided to customize window appearance and behavior. ```lua function M.open_floating_preview( contents?: string[], bufnr?: integer, syntax?: string, opts?: Hover.float_config ): integer ``` ``` ```lua local util = require('hover.util') -- Display simple text local winid = util.open_floating_preview( { 'Line 1', 'Line 2' }, nil, 'markdown', { border = 'rounded', max_width = 80 } ) -- Display pre-populated buffer local buf = vim.api.nvim_create_buf(false, true) vim.api.nvim_buf_set_lines(buf, 0, -1, false, { 'content' }) local winid = util.open_floating_preview( nil, buf, 'lua' ) ``` -------------------------------- ### Open Hover Window Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Opens the hover window, cycling to the next available provider if one is already open. Initializes hover providers on the first call. ```lua function M.open(opts?: Hover.actions.open.Options) end ``` -------------------------------- ### Diagnostics First Provider Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md Configure hover.nvim to prioritize the diagnostic provider over others like LSP. This ensures diagnostics are always shown first if present. ```lua require('hover').config({ providers = { { module = 'hover.providers.diagnostic', priority = 2000 -- Higher than LSP }, 'hover.providers.lsp', } }) -- Diagnostics always shown first if present ``` -------------------------------- ### Configure Dictionary Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Configure the hover plugin to use the Dictionary provider. This enables fetching English word definitions from an external API. ```lua require('hover').config({ providers = { 'hover.providers.dictionary', } }) ``` -------------------------------- ### actions.switch Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Cycles between available providers in the open hover window. It moves to the next or previous provider with circular wrapping and runs the selected provider's execute function. No-op if no hover window is open or only one provider is available. ```APIDOC ## actions.switch(direction, opts?) ### Description Cycles between available providers in the open hover window. It moves to the next or previous provider with circular wrapping and runs the selected provider's execute function. No-op if no hover window is open or only one provider is available. ### Method `function M.switch(direction: 'previous'|'next', opts?: Hover.Options)` ### Parameters #### Path Parameters - **direction** ('previous' | 'next') - Required - Direction to cycle - **opts** (Hover.Options) - Optional - Position and filtering options for the hover window ``` -------------------------------- ### Hover.nvim with Optional Providers Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md Configure hover.nvim to include a wider range of optional providers for enhanced functionality. ```lua require('hover').config({ providers = { 'hover.providers.diagnostic', 'hover.providers.lsp', 'hover.providers.dap', 'hover.providers.man', 'hover.providers.dictionary', 'hover.providers.gh', 'hover.providers.gh_user', 'hover.providers.jira', 'hover.providers.fold_preview', 'hover.providers.highlight', } }) ``` -------------------------------- ### Provider Initialization Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Functions and types related to initializing and defining providers for hover.nvim, enabling custom content display. ```APIDOC ## Providers (hover.providers) ### Description Handles the initialization and management of content providers for hover.nvim. ### Functions - `providers.init(config_providers)`: Initializes the provider system with custom configurations. ### Types - `Hover.Provider`: Interface for defining a custom provider. - `Hover.ProviderGroup`: Interface for grouping providers. - `Hover.Provider.Params`: Type for provider function parameters. - `Hover.Provider.Result`: Type for provider function results. ``` -------------------------------- ### Minimal Diagnostic Configuration Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md Set up vim.diagnostic with minimal formatting options, specifically disabling prefix and suffix, and setting the scope to 'cursor'. ```lua vim.diagnostic.config({ float = { scope = 'cursor', prefix = '', suffix = '', } }) ``` -------------------------------- ### util.open_floating_preview Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md Creates and opens a floating window to display hover content. It handles automatic sizing, positioning, and content formatting, with special processing for markdown. The function returns the window ID of the created floating window. ```APIDOC ## util.open_floating_preview(contents, bufnr, syntax, opts) ### Description Creates and opens a floating window displaying hover content with automatic sizing and positioning. Handles visual presentation of hover content, including markdown processing and syntax highlighting. ### Method `function M.open_floating_preview(contents?: string[], bufnr?: integer, syntax?: string, opts?: Hover.float_config): integer` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **contents** (string[]) - Optional - Array of text lines to display. Required if `bufnr` is not provided. * **bufnr** (integer) - Optional - Pre-populated buffer to display. Required if `contents` is not provided. * **syntax** (string) - Optional - Syntax type for highlighting (e.g., 'markdown', 'lua', 'python'). * **opts** (Hover.float_config) - Optional - Window configuration options. ### Request Example ```lua local util = require('hover.util') -- Display simple text local winid = util.open_floating_preview( { 'Line 1', 'Line 2' }, nil, 'markdown', { border = 'rounded', max_width = 80 } ) -- Display pre-populated buffer local buf = vim.api.nvim_create_buf(false, true) vim.api.nvim_buf_set_lines(buf, 0, -1, false, { 'content' }) local winid = util.open_floating_preview( nil, buf, 'lua' ) ``` ### Response #### Success Response (200) * **integer** - Window ID of the created floating window. #### Response Example ``` 1 ``` ### Throws * **assertion error** - Condition: Neither `contents` nor `bufnr` provided. ``` -------------------------------- ### Floating Window Positioning Logic Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/util.md Illustrates the logic for intelligent floating window positioning based on available space above/below the cursor and screen edges. ```text Lines above cursor < Lines below cursor? ├─ Yes (more space below) │ ├─ anchor = 'N' (top of window at cursor row) │ └─ height = min(available_below, requested) └─ No (more space above) ├─ anchor = 'S' (bottom of window at cursor row) └─ height = min(available_above, requested) Cursor col + width <= screen width? ├─ Yes (space on right) │ └─ anchor += 'W' (left aligned at cursor) └─ No (space on left) └─ anchor += 'E' (right aligned at cursor) Final anchors: 'NW', 'NE', 'SW', 'SE' ``` -------------------------------- ### hover.open Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference.md Opens the hover window at the current cursor position, displaying content from registered providers. If a hover window is already open, it cycles to the next available provider. Otherwise, it displays the first available provider. ```APIDOC ## hover.open(opts?) ### Description Opens the hover window at the current cursor position, displaying content from registered providers. ### Method `function` ### Parameters #### Optional Parameters - **opts** (Hover.actions.open.Options) - Optional - Options object for hover window - **bufnr** (integer) - Optional - Buffer number to hover over (default: current buffer) - **pos** ([integer, integer]) - Optional - Position as [row, col] (1-indexed) (default: current cursor) - **relative** (string) - Optional - Window positioning relative to cursor, mouse, or win - **providers** (string[]) - Optional - Filter to specific provider module names ### Returns - **void** - Triggers asynchronous hover display ### Behavior If a hover window is already open, cycles to the next available provider. Otherwise, displays the first available provider. Providers are filtered by their `enabled` function and the `opts.providers` whitelist. ### Example ```lua require('hover').open() -- With options require('hover').open({ pos = { 10, 5 }, providers = { 'hover.providers.lsp' } }) ``` ``` -------------------------------- ### Configure Man Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/other-providers.md Configure the hover plugin to use the Man provider. This enables displaying manual pages for supported languages. ```lua require('hover').config({ providers = { 'hover.providers.man', } }) ``` -------------------------------- ### Implement Async Provider Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/providers.md Implement a provider that performs asynchronous operations using the `hover.async` module. This prevents blocking the UI during long-running tasks like network requests. ```lua local async = require('hover.async') return { name = 'Async Provider', execute = function(params, done) async.run(function() local result = async.await(2, system, { 'curl', 'https://api.example.com' }) done({ lines = vim.split(result.stdout, '\n') }) end) end } ``` -------------------------------- ### Configure Mouse Hover Providers Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/configuration.md Define a subset of providers to be used specifically for mouse hover events triggered by `require('hover').mouse()`. This allows for different provider behavior when using the mouse versus other triggers. ```lua config.mouse_providers = { 'hover.providers.lsp' } ``` ```lua mouse_providers = { 'hover.providers.lsp', 'hover.providers.diagnostic', } ``` -------------------------------- ### Hover.nvim File Structure Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Provides a hierarchical view of the hover.nvim plugin's directory and file organization, highlighting the main modules and provider subdirectories. ```text hover.nvim/ ├── lua/ │ └── hover/ │ ├── init.lua (entry point) │ ├── actions.lua (window control) │ ├── async.lua (async utilities) │ ├── config.lua (configuration) │ ├── highlights.lua (UI styling) │ ├── providers.lua (provider system) │ ├── util.lua (floating window) │ └── providers/ (built-in providers) │ ├── dap.lua │ ├── diagnostic.lua │ ├── dictionary.lua │ ├── fold_preview.lua │ ├── gh.lua │ ├── gh_user.lua │ ├── highlight.lua │ ├── jira.lua │ ├── lsp.lua │ └── man.lua └── README.md (project readme) ``` -------------------------------- ### Usage Pattern: Wrapping External APIs Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/async.md This pattern demonstrates wrapping `vim.system` and `vim.schedule` using `async.wrap` and `async.scheduler` respectively, allowing them to be used seamlessly within an `async.run` block for sequential async operations and UI updates. ```lua local async = require('hover.async') local system = async.wrap(2, vim.system) local schedule = async.scheduler async.run(function() print('Starting...') -- Call async function local result = system({ 'whoami' }) -- Schedule main-thread operation schedule() vim.notify('User: ' .. vim.trim(result.stdout)) end) ``` -------------------------------- ### config.get() Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md Returns the current hover configuration. If the configuration has not yet been set, it returns the default configuration values. ```APIDOC ## config.get() Returns the current configuration, or defaults if not yet configured. ### Returns - **Hover.Config** - Current merged configuration object. ``` -------------------------------- ### Registering Multiple Providers with a Group Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/types.md Shows the pattern for returning a Hover.ProviderGroup from a module to register multiple related providers. ```lua return { name = 'LSP', priority = 1000, providers = { { name = 'Client1', execute = ... }, { name = 'Client2', execute = ... }, } } ``` -------------------------------- ### hover.config() Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/FILES.txt Configures the hover.nvim plugin, allowing modification of its behavior and appearance. ```APIDOC ## hover.config() ### Description Configures the hover.nvim plugin. This function allows setting various options to customize behavior and appearance. ### Method `hover.config(options)` ### Parameters - **options** (table) - Required - A table containing configuration options. Refer to `configuration.md` for details. ### Request Example ```lua hover.config({ provider = 'lsp', theme = 'dark' }) ``` ### Response None explicitly documented, but implies configuration changes are applied. ``` -------------------------------- ### Configuration Functions Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/README.md Functions for managing the configuration of the hover.nvim plugin, allowing users to set and retrieve configuration options. ```APIDOC ## Configuration (hover.config) ### Description Manages the configuration settings for the hover.nvim plugin. ### Functions - `config.set(user_config)`: Sets the user-specific configuration for the plugin. - `config.get()`: Retrieves the current configuration of the plugin. ``` -------------------------------- ### Check Attached LSP Clients Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/lsp-provider.md View all attached LSP clients in the current buffer using the :LspInfo command. ```vim -- View all attached LSP clients in current buffer :LspInfo ``` -------------------------------- ### Using the Async Scheduler Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/async.md The `async.scheduler` is a pre-wrapped version of `vim.schedule` that yields control back to Neovim's main event loop. This is essential for scheduling UI updates after asynchronous operations. ```lua local async = require('hover.async') async.run(function() -- Do some async work local result = async.await(vim.system, { 'curl', 'url' }) -- Schedule UI update async.scheduler() -- Now safe to update UI vim.notify('Result: ' .. result.stdout) end) ``` -------------------------------- ### Prefix Format: Table with Highlight Group Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/diagnostic-provider.md Use a table to specify text and its associated highlight group for the prefix. This allows for styled prefixes. ```lua prefix = { '[E] ', 'ErrorMsg' } -- Result: "[E] " in ErrorMsg highlight, message in normal ``` -------------------------------- ### async.run Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/async.md Executes an async function (coroutine) with arguments, handling completion callbacks. This function is the entry point for running asynchronous tasks. ```APIDOC ## async.run ### Description Executes an async function (coroutine) with arguments, handling completion callbacks. ### Function Signature ```lua function M.run(async_fn: async fun(...:T...): R..., ...: T...): void ``` ### Parameters #### Parameters - **async_fn** (async fun(...:T...): R...) - Coroutine function that yields to await - **...** (any) - Arguments passed to async_fn ### Returns #### Returns - **void** - Executes asynchronously; completion is handled via callbacks in async_fn ### Example ```lua local async = require('hover.async') async.run(function() print('Starting') -- Execute async operations here print('Done') end) ``` ``` -------------------------------- ### LSPProvider Class Definition Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/lsp-provider.md Defines the LSPProvider class with a constructor and an 'enabled' method to check if a client supports hover. The 'execute' method is a placeholder for sending the hover request. ```lua --- @class LSPProvider --- @field client_id integer local LSPProvider = {} function LSPProvider:new(client_id) return setmetatable({ client_id = client_id }, self) end function LSPProvider:enabled(bufnr) local client = lsp.get_clients({ id = self.client_id, bufnr = bufnr, method = 'textDocument/hover' })[1] return (client and lsp_providers[client.id]) ~= nil end function LSPProvider:execute(params, done) -- Send hover request to LSP server end ``` -------------------------------- ### Manage Hover Window Focus Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/actions.md Manages the focus state when opening a new hover window. It either returns to the previous window, focuses the existing hover window, or returns nil. ```lua local function focus_or_close_floating_window(): integer? end ``` -------------------------------- ### Hover.UserConfig Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/config.md Defines the complete user-facing configuration interface for hover.nvim. Allows customization of preview windows, titles, providers, mouse behavior, and more. ```APIDOC ## Hover.UserConfig Complete user-facing configuration interface. ### Fields - **preview_window** (boolean) - Optional - Move hover content to preview window instead of floating. - **title** (boolean) - Optional - Show provider tabs in hover window. - **providers** (string[] | Hover.Config.Provider[]) - Optional - Modules to load as hover providers. Defaults to built-in providers. - **mouse_providers** (string[]) - Optional - Providers to use for mouse hover. Defaults to `{'hover.providers.lsp'}`. - **mouse_delay** (integer) - Optional - Milliseconds before showing hover on mouse movement. Defaults to 1000. - **preview_opts** (vim.api.keyset.win_config) - Optional - Floating window configuration. Defaults to `{border = 'single'}`. - **dev_mode** (boolean) - Optional - Show errors instead of silently handling them. Defaults to false. - **init** (fun()) - Optional - Callback invoked before first hover action. Defaults to nil. ``` -------------------------------- ### Initialize Highlight Groups Source: https://github.com/lewis6991/hover.nvim/blob/main/_autodocs/api-reference/highlights.md Initializes hover.nvim highlight groups by linking them to default Vim highlight groups if not already defined. This function is called automatically by `require('hover').config()`. ```lua function M.setup() ``` ```lua require('hover.highlights').setup() ```