Skip to content

riodelphino/cheat.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cheat.nvim

Quick & Usefull cheatsheet viewer plugin for nvim.

Inspired by vim-cheatsheet

Showcase

Show cheatsheets by user commands.

:Cheat or :Cheat {cheat_name}

capture01.mov

Show cheatsheets by keymaps.

<leader>ch or <leader>cn or <leader>ct

capture02.mov

Functions

Both functions are available.

  1. Show 'filetype-specific' cheatsheet automatically, with the same 'one' keymap.
    ex.) <leader>ch or :Cheat

  2. Show 'commonly-used' cheatsheet, by each keymaps.
    ex.) <leader>cn or :Cheat nvim --> nvim's cheatsheet
    ex.) <leader>ct or :Cheat tmux --> tmux's cheatsheet

Install

Packer

use { "riodelphino/cheat.nvim" }

Setup

require('cheat').setup {}

Usage

Command Description
:Cheat Show the cheatsheet depending on current buf's filetype,
with the style set in config.window.default_style.
:Cheat {cheat_name} Same with :Cheat, but show the specific cheatsheet.
:CheatFloat Same with :Cheat, but with float style. (Sorry, not implemented now.)
:CheatHSplit Same with :Cheat, but with horizontal split style. (Sorry, not implemented now.)
:CheatVSplit Same with :Cheat, but with vertical split style. (Sorry, not implemented now.)

Default keymaps

Keymap Function
<leader>ch Show the cheatsheet delepending on current buf's file pattern
<leader>cn Show the nvim's cheatsheet (cheat-nvim.md)
<leader>ct Show the tmux's cheatsheet (cheat-tmux.md)
q Close cheatsheet.

Config

Default configs.

rquire('cheat').setup {
   debug = false, -- show debug msg (just for me)
   readonly = true, -- 'false' for editable.
   window = {
      default_style = "float",     -- "vsplit", "hsplit" -- Choose display style. (Now only 'float' works.)
      vsplit = { height = { size = 20 } },
      hsplit = { width = { size = 40 } },
      float = {
         width = {
            ratio = 0.8,
         },
         height = {
            ratio = 0.9,
         },
         signcolumn = false, -- 'false' for simple display style.
      },
   },
   file = {
      dir = "~/.config/nvim/cheat", -- Directory where the cheatsheets are placed.
      prefix = "cheat-", -- Cheatsheet file prefix.
      ext = ".md", -- Cheatsheet extension.
   },
   keymaps = {
      ["<leader>ch"] = ":Cheat", -- Show the cheatsheet depending on filetype.
      ["<leader>cn"] = ":Cheat nvim", -- Show "cheat-nvim.md"
      ["<leader>ct"] = ":Cheat tmux", -- Show "cheat-tmux.md"
      -- Add more keymaps & cheatsheets here.
   },
   cheatsheets = {
      filetypes = { -- Open the specific cheatsheet by file pattern.
         lua = { "*.lua" },
         vim = { "*.vim", "*.vifmrc" }, -- The key 'vim' is the surfix of filename. ex.) cheat-vim.md
         js = { "*.js", "*.mjs" },
         css = { "*.css", "*.scss", "*.sass" },  -- Multiple filetypes are allowed.
         md = { "*.md" },
         php = { "*.php" },
         html = { "*.html" },
         -- Add more filetypes settings here.
      },
   },
}

TODO

  • window.default_style = "vsplit"
  • window.default_style = "hsplit"
  • window.vsplit.signcolumn
  • window.vsplit.signcolumn
  • Logging (now just print()...)

Lisence

MIT