Ecosyste.ms: Awesome

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

https://github.com/RishabhRD/nvim-cheat.sh

cheat.sh integration for neovim in elegant way
https://github.com/RishabhRD/nvim-cheat.sh

cheetsheet lua neovim neovim-plugin popfix

Last synced: 11 days ago
JSON representation

cheat.sh integration for neovim in elegant way

Lists

README

        

# nvim-cheat.sh

[cheat.sh](https://github.com/chubin/cheat.sh) integration for neovim.

nvim-cheat.sh provides elegant UI and remove complexity of url handling and
special symbols for users.

## Screenshots

![](https://user-images.githubusercontent.com/26287448/103154931-3ba71d00-47c1-11eb-9844-2c706e5d9b09.gif)

## Installation

Install with your favorite plugin manager. For example with vim-plug:

```lua
Plug 'RishabhRD/popfix'
Plug 'RishabhRD/nvim-cheat.sh'
```

## Working

The plugin exports 4 commands:

- Cheat
- CheatWithoutComments
- CheatList
- CheatListWithoutComments

Each command accepts 0 or more arguments. Arguments decide the initial prompt
text.

CheatWithoutComments search the query but don't display the (optional) comments.

Example:
```vim
:Cheat
:Cheat cpp reverse number
:CheatWithoutComments
:CheatWithoutComments cpp reverse number
```

First and third command opens the prompt to search with and without comments
respectively.

Second and fourth command opens the prompt with initial prompt text
``cpp reverse number`` to search with and without comments respectively.

CheatList and CheatListWithoutComments provides fuzzy finding from all available symbols.

## Changing result layout
By default result is displayed in a floating window. However, this may be
disturbing for some users. Hence, nvim-cheat.sh provides a global variable
`g:cheat_default_window_layout` with which users can set their default layout.

Example:
```lua
vim.g.cheat_default_window_layout = 'split'
```

Possible values are:
- split
- vertical_split
- tab
- float

**Note:** If provided any wrong value, float will be used.

## How to query

Plugin behavior is similar to cheat.sh behavior.

The first word should be the language for query. (e.g. cpp)

Rest of words define the query. (e.g. sum of digits)

An example query:

```
cpp sum of digits
```

Try to put the language name matching vim filetype for the corresponding
language. This would also enable syntax highlighting for result.
Example: using ``javascript`` for javascript language would produce syntax
highlighting. However, using ``js`` for javascript would not as vim recognise
``javascript`` as filetype not ``js``.

For having different results for the same query append \1, \2, etc to query similar to
classic cheat.sh.

Example: ``cpp read file\1``

## Keymaps

Keymaps for prompt are:

In insert mode:

- **\** : Open result in default layout.
- **\** : Open result in horizontal split.
- **\** : Open result in a new tab.
- **\** : Open result in a vertical split.
- **\** : Open result in floating window.
- **\** : Open result in floating window.
- **\** : Close window without any action.
- **\** : Previous in history
- **\** : Next in history

In normal mode:

- **\** : Open result in default layout.
- **\** : Open result in horizontal split.
- **\** : Open result in a new tab.
- **\** : Open result in a vertical split.
- **\** : Open result in floating window.
- **\** : Open result in floating window.
- **\** : Close window without any action.
- **\** : Close window without any action.
- **q** : Close window without any action.
- **k** : Previous in history
- **j** : Next in history