cheat.sh integration for neovim.
nvim-cheat.sh provides elegant UI and remove complexity of url handling and special symbols for users.
Install with your favorite plugin manager. For example with vim-plug:
Plug 'RishabhRD/popfix'
Plug 'RishabhRD/nvim-cheat.sh'
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:
: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.
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:
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.
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 for prompt are:
In insert mode:
- <CR> : Open result in default layout.
- <C-x> : Open result in horizontal split.
- <C-t> : Open result in a new tab.
- <C-v> : Open result in a vertical split.
- <C-y> : Open result in floating window.
- <C-f> : Open result in floating window.
- <C-c> : Close window without any action.
- <C-p> : Previous in history
- <C-n> : Next in history
In normal mode:
- <CR> : Open result in default layout.
- <C-x> : Open result in horizontal split.
- <C-t> : Open result in a new tab.
- <C-v> : Open result in a vertical split.
- <C-y> : Open result in floating window.
- <C-f> : Open result in floating window.
- <C-c> : Close window without any action.
- <Esc> : Close window without any action.
- q : Close window without any action.
- k : Previous in history
- j : Next in history