Code Monkey home page Code Monkey logo

cheatsheet.nvim's Introduction

Hi ! I'm Gokul Soumya ๐Ÿ‘‹

I'm a college senior from India, doing my engineering degree in CS.

I love the command line and spend most of my time there :)

I'm currently working on...

  1. Helix - A modern text editor inspired from vim and kakoune
  2. A note-taking app similar to Obsidian

cheatsheet.nvim's People

Contributors

samclercky avatar sudormrfbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cheatsheet.nvim's Issues

nil value error

Hello, thank you for the plugin.
Stumbled upon an error, I get the

Error detected while processing function <SNR>51_Cheatsheet:
line    5:
E5108: Error executing lua ...vim/plugged/cheatsheet.nvim/lua/cheatsheet/telescope.lua:45: attempt to compare number with nil

When trying to invoke :Cheatsheet while having this telescope configuration:

require('telescope').setup{
    defaults = {
    	    layout_strategy = "bottom_pane",
	},
}

Feature Request: allow user-defined cheats to replace default cheats

Imagine you prefer a different keybinding for some function over the default, and thus go on to change a plugin setting or remap a default key.
Imagine further you add an entry to your cheatsheet.txt to reflect this new reality.

Wouldn't it be great, if cheatsheet.nvim would now stop showing you two conflicting cheat entries for cheats that are defined elsewhere as well?

Maybe filtering based on the same description could work.

E5108: Error executing lua ...attempt to compare number with nil

I have installed the plugin with

    use {
        'sudormrfbin/cheatsheet.nvim',

        requires = {
            {'nvim-telescope/telescope.nvim'},
            {'nvim-lua/popup.nvim'},
            {'nvim-lua/plenary.nvim'},
        }
    }

When running :Cheatsheet or pressing <leader>? I get:

Error detected while processing function <SNR>50_Cheatsheet:
line    5:
E5108: Error executing lua ...acker/start/cheatsheet.nvim/lua/cheatsheet/telescope.lua:44: attempt to compare number with nil

If you need more info of my config let me know :)

Bundled plugins' cheatsheets aren't loading

For example, I have vim-sandwich installed, however it's cheatsheet (which is apparently bundled) doesn't load.
After investigation, I found out that plugin_include table in init.lua forms weirdly, with trailing slashes.
Here's what print(vim.inspect(plugin_include)) says:

Output
{
enabled = { "nvim", "nvim", "site", "packer.nvim", "site", "site", "runtime", "matchit", "nvim", "vimfiles", "cheatsheet.nvim/", "completion-nvim/", "completion-tabnine/", "kommentary/", "
nvim-autopairs/", "nvim-lspconfig/", "nvim-treesitter/", "nvim-ts-context-commentstring/", "nvim-ts-rainbow/", "onedark.nvim/", "packer.nvim/", "plenary.nvim/", "popup.nvim/", "suda.vim/", "
telescope.nvim/", "todo-comments.nvim/", "vim-easy-align/", "vim-sandwich/", "vim-smoothie/", "vim-xkbswitch/", "which-key.nvim/", "after", "after", "after", "after", "after", "after/", "aft
er/" }
}

It may or may not be related, perhaps I'm missing something obvious...

Third column missing

I just wanted to give this plugin a quick try, but on my system, the third column is missing:

grafik

relevant part of my config:

use {
  'sudormrfbin/cheatsheet.nvim',
  requires = {
    {'nvim-telescope/telescope.nvim'},
    {'nvim-lua/popup.nvim'},
    {'nvim-lua/plenary.nvim'},
  },
  config = function ()
    mapleader("hh", ":Cheatsheet<CR>")
  end
}

my telescope config (in case thats relevant):

use {
    'nvim-telescope/telescope.nvim',
    requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}},
    config = function()

    local actions = require('telescope.actions')

    require('telescope').setup{
      defaults = {
        vimgrep_arguments = {
          'rg',
          '--color=never',
          '--no-heading',
          '--with-filename',
          '--line-number',
          '--column',
          '--smart-case'
        },
        prompt_position = "bottom",
        prompt_prefix = "> ",
        selection_caret = " ",
        entry_prefix = "  ",
        initial_mode = "insert",
        selection_strategy = "reset",
        sorting_strategy = "descending",
        layout_strategy = "center",
        layout_defaults = {
          horizontal = {
            mirror = false,
          },
          vertical = {
            mirror = false,
          },
        },
        file_sorter =  require'telescope.sorters'.get_fuzzy_file,
        file_ignore_patterns = {},
        generic_sorter =  require'telescope.sorters'.get_generic_fuzzy_sorter,
        shorten_path = true,
        winblend = 0,
        width = 0.55,
        preview_cutoff = 120,
        results_height = 15,
        results_width = 0.8,
    		results_title = false,
        border = {},
    		borderchars = {
          { 'โ”€', 'โ”‚', 'โ”€', 'โ”‚', 'โ•ญ', 'โ•ฎ', 'โ•ฏ', 'โ•ฐ'},
          prompt = {"โ”€", "โ”‚", " ", "โ”‚", "โ•ญ", "โ•ฎ", "โ”‚", "โ”‚"},
          results = {"โ”€", "โ”‚", "โ”€", "โ”‚", "โ”œ", "โ”ค", "โ•ฏ", "โ•ฐ"},
          preview = { 'โ”€', 'โ”‚', 'โ”€', 'โ”‚', 'โ•ญ', 'โ•ฎ', 'โ•ฏ', 'โ•ฐ'},
        },
        color_devicons = true,
        use_less = true,
        set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil,
        file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
        grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
        qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
    		mappings = {
    			i = {
    				["C-j"] = actions.move_selection_next,
    				["C-k"] = actions.move_selection_previous,
    			},
    			n = {
    				["C-c"] = actions.close,
    			}
    		},

        -- Developer configurations: Not meant for general override
        buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker
      }
    }

    -- Telescope
    function search_nvim_config()
        require("telescope.builtin").find_files(
            {
                prompt_title = "Neovim Config",
                cwd = "$HOME/.config/nvim/"
            }
        )
    end


    map("n", "z=", "<Cmd>:Telescope spell_suggest<CR>", { noremap = true, silent = true })
    map("n", "gr", "<Cmd>:Telescope lsp_references<CR>", { noremap = true, silent = true })

    mapleader("<space>", "<Cmd>:Telescope find_files<CR>")
    mapleader("?", "<Cmd>:Telescope keymaps<CR>")
    mapleader("h:", "<Cmd>:Telescope help_tags<CR>")
    mapleader("bb", "<Cmd>:Telescope buffers<CR>")
    mapleader("ff", "<Cmd>:Telescope file_browser<CR>")
    mapleader("fg", "<Cmd>:Telescope live_grep<CR>")
    mapleader("fc", "<Cmd>:lua search_nvim_config()<CR>")

    end
}

link to my entire config, in case it's something else: https://codeberg.org/B4rc1/nvim-config (does not have the cheatsheet snippet i posted here, because I don't (yet ;)) want it on my other machines)


nvim --version

NVIM v0.5.0-dev+1447-g5c0b01fd8
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions     -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security     -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/jonas/.cache/paru/clone/neovim-git/src/build/config -I/home/jonas/.cache/paru/clone/neovim-git/src/neovim-git/src -I/usr/include -I/home/jonas/.cache/paru/clone/neovim-git/src/build/src/nvim/auto -I/home/jonas/.cache/paru/clone/neovim-git/src/build/include

Add another key-binding to execute commands directly.

Hi. I'm using cheatsheet.nvim and mostly use it to call/run my custom commands and functions.

The only annoying issue is that it always filled in the command line if the selection row is a command.

I think you designed it in this way to let users edit the commands before run it? But me personally (for 90% of time) don't need to edit commands and just need to run them immediately.

In my opinion, we can add another keybinding like <Ctrl-r> (or whatever you prefer) for filling the command line and keep the <ENTER> to execute commands directly.

How to make Cheatsheet.txt dynamic?

hi @sudormrfbin , very cool plugin! Im liking it so far but one thing bugs me . We can write our mappings in cheatsheet.txt , Is there anyway to make this automatic?

Im trying to add this plugin in NvChad and the user config contains this

image

So obviously I cant define any mappings in the cheatsheet.txt since the user would change his mappings here and would have to manually do it again in cheatsheet.txt :c .

Is there a way get all defined mappings ( keys and their cmds) and get it work with cheatsheet.nvim?

default chentoast/marks.nvim cheatsheet

## marks  @bookmark
Set mark x.                                    | m{x}
Set the next available alphabetical mark.      | m,
Toggle the next available mark.                | m;
Delete mark x.                                 | dm{x}
Delete all marks on the current line.          | dm-
Delete all marks in the current buffer.        | dm<SPC>
Move to next mark.                             | m]
Move to previous mark.                         | m[
Preview mark.                                  | m:
Add a bookmark from bookmark group[0-9].       | m{0-9}
Delete the bookmark under the cursor.          | dm=
Delete all bookmarks from bookmark group[0-9]. | dm{0-9}
Move to next bookmark of same type.            | m}
Move to previous bookmark of same type.        | m{

Alt-Enter doesn't work for commands with placeholders and hotkeys

Hi,

I noticed a couple of issues with Alt+Enter.

If I press Alt+Enter for the built-in 'find-and-replace' command :s/{P}/{P}/g then I get:

E5108: Error executing lua ...src/cheatsheet.nvim/lua/cheatsheet/telescope/actions.lua:27: Vim(substitute):E486: Pattern not found: {P}
stack traceback:
        [C]: in function 'nvim_command'
        ...src/cheatsheet.nvim/lua/cheatsheet/telescope/actions.lua:27: in function 'select_current_item'
        ...src/cheatsheet.nvim/lua/cheatsheet/telescope/actions.lua:63: in function 'action'
        ...r1/src/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:94: in function 'key_func'
        ...e/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:338: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

If I press Alt+Enter for hotkeys like gg to go to the first line then it just doesn't work. I'm not sure if it's a bug or a missing feature.

I looked into the code in actions.lua and I don't get the idea behind it. To me it just looks wrong.

The code is introduced in commit 9716f9a. It's related to issue #11 and PR #12

I fixed the problems and I can create a PR.

The only remaining problem for me is that if I press Enter for a cheat in Telescope then the cheat doesn't get printed at the bottom of the screen. I suspect that it's a regression from telescope. Maybe I will try to look into it later and I will create a separate issue then.

Best regards,
Stan

Disabling nerd-fonts cheatsheet does not work

I am using the following setup:

require("cheatsheet").setup({
    bundled_cheetsheets = {
        enabled = { "default", "regex", "netrw" },
        disabled = { "nerd-fonts" } -- also tried "nerdfonts"
    },
})

However, I still see nerd-fonts being added to the list:
nerd fonts in list screenshot

corrected and completed gitsigns cheatsheet

## gitsigns @git
Next hunk                                | ]c
Previous hunk                            | [c
Stage hunk                               | <leader>hs
Undo stage hunk                          | <leader>hu
Reset hunk                               | <leader>hr
Preview hunk                             | <leader>hp
Stage buffer                             | <leader>hS
Reset buffer                             | <leader>hR
Blame current line                       | <leader>hb
Toggle blame current line                | <leader>tb
Diff this                                | <leader>hd
Diff home                                | <leader>hD
Toggle show deleted                      | <leader>td
Hunk text object                         | ih 

Updates

Subscribe to this issue to get notified of new features in cheatsheet.nvim :P

cheatsheet.nvim with Telescope

cheatsheet.nvim gif

Error while invoking command on LunarVim

I've recently tried LunarVim distro, and it seems that it fails when invoking. I used lazy.nvim to load it using LazyVim distro before and it worked without hiccups. Please let me know if I can share more info.

Config

lvim.plugins = {
    "sudormrfbin/cheatsheet.nvim",
    dependencies = {
      'nvim-telescope/telescope.nvim',
      'nvim-lua/popup.nvim',
      'nvim-lua/plenary.nvim',
    }
}

Error:

Error detected while processing function <SNR>10_Cheatsheet:
line    5:
E5108: Error executing lua ...zy/opt/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:47: attempt to compare number with function
stack traceback:
        ...zy/opt/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:47: in function 'entry_maker'
        ...scope.nvim/lua/telescope/finders/async_static_finder.lua:17: in function 'new_table'
        ...zy/opt/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:26: in function 'pick_cheat'
        ...te/pack/lazy/opt/cheatsheet.nvim/lua/cheatsheet/init.lua:186: in function 'show_cheatsheet_telescope'
        ...te/pack/lazy/opt/cheatsheet.nvim/lua/cheatsheet/init.lua:193: in function 'show_cheatsheet'

Error on detected while processing: telescope.actions not found

I am trying to make this plugin work on windows, I have all the setup for neovim 0.6 and other plugins working, including Telescope and others. when I load Cheatsheet command, I get the following error:

Error detected while processing function <SNR>67_Cheatsheet:
line    5:
E5108: Error executing lua ...art\cheatsheet.nvim/lua/cheatsheet/telescope/actions.lua:1: module 'telescope.actions' not found:
        no field package.preload['telescope.actions']
        no file '.\telescope\actions.lua'
        no file 'C:\tools\neovim\Neovim\bin\lua\telescope\actions.lua'
        no file 'C:\tools\neovim\Neovim\bin\lua\telescope\actions\init.lua'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\share\lua\5.1\telescope\actions.lua'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\share\lua\5.1\telescope\actions\init.lua'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\lib\luarocks\rocks-5.1\telescope\actions.lua'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\lib\luarocks\rocks-5.1\telescope\actions\init.lua'
        no file '.\telescope\actions.dll'
        no file 'C:\tools\neovim\Neovim\bin\telescope\actions.dll'
        no file 'C:\tools\neovim\Neovim\bin\loadall.dll'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\lib\lua\5.1\telescope\actions.so'
        no file '.\telescope.dll'
        no file 'C:\tools\neovim\Neovim\bin\telescope.dll'
        no file 'C:\tools\neovim\Neovim\bin\loadall.dll'
        no file 'C:\Users\Spark\AppData\Local\Temp\nvim\packer_hererocks\2.1.0-beta3\lib\lua\5.1\telescope.so'
stack traceback:
        [C]: in function 'require'
        ...art\cheatsheet.nvim/lua/cheatsheet/telescope/actions.lua:1: in main chunk
        [C]: in function 'require'
        ...k\packer\start\cheatsheet.nvim/lua/cheatsheet/config.lua:26: in main chunk
        [C]: in function 'require'
        ...ack\packer\start\cheatsheet.nvim/lua/cheatsheet/init.lua:2: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

Not sure what went wrong here! Let me know if you need any other logs/information from my side.

Reverse cheatsheet.txt for easier to edit.

Most of the cheatsheet of other documents is write with a format:
key : describtion

While cheatsheet.nvim write in reverse:
describtion | key

It cost time to edit after copy from a document.

Add all Ex commands

When I know part of an Ex command, I can use :Telescope commands to find it.

It would be nice to have all the Ex commands on Cheatsheet instead of having to toggle between :Cheatsheet and :Telescope commands.

It's possible to have an overlap between the commands that have been manually added into :Cheatsheet and the ones from :Telescope commands, in those cases maybe showing the command from Cheatsheet would be preferable, because those have human descriptions whilst the ones from :Telescope commands don't.

FEATURE REQUEST: Execute command on ENTER (if possible)

Hello @sudormrfbin ,

I really like your plugin and want to use it.

When looking at your plugin, I missed the feature where you could immediately execute the selected command or when the telescope window closes, I can't see the exact command anymore.

For this reason, I forked your plugin and implemented it myself but wasn't sure if you would want something like this since you already added a function to the ENTER key.

If you like my idea, I can do a pull request ๐Ÿ˜ƒ

Sam Clercky

Ps. Repo: https://github.com/SamClercky/cheatsheet.nvim

Integration with folke/whichkey.nvim?

I'm getting my mappings set up in https://github.com/folke/which-key.nvim and was just thinking how nice it'd be if this integrated with which-key.nvim so that I could define my keymaps there and be able to search the labels of the keybindings that are given there with this tool. If I use cheatesheet.nvim, I'd basically need to be typing out those descriptions twice, and I'd love it if I could save myself the hassle ๐Ÿ™‚

I understand that this kinda goes against the premise, however it feels like a fit that would "make sense" and be an awesome convenience for the folks who've already spent a bunch of time getting their which-key configs set up.

Error detected while processing function <SNR>31_Cheatsheet:

Hi,

I really love this plugin, however recently I came across with one issue that I don't know how to solve.

When I try to open the cheatsheet I get this error:

Error detected while processing function <SNR>31_Cheatsheet:
line    5:
E5108: Error executing lua .../start/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:43: attempt to index a nil value
stack traceback:
	.../start/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:43: in function 'entry_maker'
	...scope.nvim/lua/telescope/finders/async_static_finder.lua:17: in function 'new_table'
	.../start/cheatsheet.nvim/lua/cheatsheet/telescope/init.lua:26: in function 'pick_cheat'
	...ack/packer/start/cheatsheet.nvim/lua/cheatsheet/init.lua:186: in function 'show_cheatsheet_telescope'
	...ack/packer/start/cheatsheet.nvim/lua/cheatsheet/init.lua:193: in function 'show_cheatsheet'
	[string ":lua"]:1: in main chunk

In order to replicate the error you need to setup flex as a default layout strategy

require('telescope').setup{
    defaults = {
    	    layout_strategy = "flex",
	},
}

Any insights about this issue would be appreciate it
thank you in advance!

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.