Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Tyler-Barham/floating-help.nvim

📚 A Neovim plugin to show `:help` in an anchorable/resizable floating window
https://github.com/Tyler-Barham/floating-help.nvim

lua neovim neovim-plugin nvim

Last synced: 3 months ago
JSON representation

📚 A Neovim plugin to show `:help` in an anchorable/resizable floating window

Awesome Lists containing this project

README

        

# 📚 FloatingHelp

A Neovim plugin to show :help, cppman, or man in an anchorable/resizable floating window.

![FloatingHelp Screenshot](./media/floating-help-active.png)
`:FloatingHelp dap.txt position=NE height=0.55`

![FloatingHelp Screenshot](./media/floating-help-inactive.png)
`:FloatingHelp test position=SW height=0.5 width=40`

## ⚒️ Installation

Install with your preferred plugin manager:

```lua
-- packer.nvim
use 'Tyler-Barham/floating-help.nvim'
```

Optionally, install [cppman](https://github.com/aitjcize/cppman)

## ⚙️ Configuration

### Setup

You need to call the `setup()` method to initialize the plugin

```lua
local fh = require('floating-help')

fh.setup({
-- Defaults
width = 80, -- Whole numbers are columns/rows
height = 0.9, -- Decimals are a percentage of the editor
position = 'E', -- NW,N,NW,W,C,E,SW,S,SE (C==center)
border = 'rounded', -- rounded,double,single
onload = function(query_type) end, -- optional callback to be executed after help contents has been loaded
})

-- Create a keymap for toggling the help window
vim.keymap.set('n', '', fh.toggle)
-- Create a keymap to search cppman for the word under the cursor
vim.keymap.set('n', '', function()
fh.open('t=cppman', vim.fn.expand(''))
end)
-- Create a keymap to search man for the word under the cursor
vim.keymap.set('n', '', function()
fh.open('t=man', vim.fn.expand(''))
end)

-- Only replace cmds, not search; only replace the first instance
local function cmd_abbrev(abbrev, expansion)
local cmd = 'cabbr ' .. abbrev .. ' =(getcmdpos() == 1 && getcmdtype() == ":" ? "' .. expansion .. '" : "' .. abbrev .. '")'
vim.cmd(cmd)
end

-- Redirect `:h` to `:FloatingHelp`
cmd_abbrev('h', 'FloatingHelp')
cmd_abbrev('help', 'FloatingHelp')
cmd_abbrev('helpc', 'FloatingHelpClose')
cmd_abbrev('helpclose', 'FloatingHelpClose')
```

## 🚀 Usage

### Commands

- `FloatingHelp `
- `FloatingHelpToggle `
- `FloatingHelpClose`

Args (none are positional):

- `` The help page to show
- `p[osition]=`
- `h[eight]=`
- `w[idth]=`
- `t[ype]=`

### API

```lua
local fh = require('floating-help')

fh.open({args})
fh.toggle({args})
fh.close()
```

## 🤝 Contributing

All contributions are welcome! Just open a pull request.