Coder Social home page Coder Social logo

nvim-cheat.sh's Introduction

nvim-cheat.sh

cheat.sh integration for neovim.

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

Screenshots

Installation

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

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:

: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:

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:

  • <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

nvim-cheat.sh's People

Contributors

dagle avatar rishabhrd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.