Code Monkey home page Code Monkey logo

vim-be-good's Introduction

vim-be-good

Vim be good is a plugin designed to make you better at vim by creating a game to practice basic movements in.

Programmed with Love and Fury

and tunes https://www.youtube.com/watch?v=emOKaGi8u5U

WARNING

  • The code is a heaping pile of awfulness. It was developed live on Twitch, which means I did not carefully think through anything other than memes.
  • If you wish to create your own game, look at how relative is done. Everything else should be straight forward, except for the parts that are not.

Difficulty

The difficulty only works on a few games for now. Still a work in progress, if you have any ideas, please submit them either as tickets or as a PR.

Ideas?

Please submit a ticket for your idea!!!

Options

Games - relative

By default vim be good returns random offset for game difficulty above noob, if you wish to set fixed offset set vim_be_good_delete_me_offset to desired value.

let g:vim_be_good_delete_me_offset = 35

Instructions are at the top of games.

here too!

To play relative you need to delete the line that says DELETE ME. Use relative jumps

To play ci{ you need to replace the contents inside the first { or [ with bar. HINT, use ci[ or ci{ and type bar.

To play whackamole you need to navigate to the character with the caret under it as fast as possible. Once you have reached the character, flip the character's case to complete the round.

Installation

MUST USE NEOVIM 5.x!!!!!!

  1. Use your favorite plugin manager to install! Only works on Nvim, the one true vim.
Plug 'ThePrimeagen/vim-be-good'

Docker

If you would like, you can use docker to run the game. Doing this will automatically use the correct version of neovim for you, as well as run the game immediately when neovim starts.

Stable image

This image always runs the version of the game that was bundled when the image was built. Images are generally built within one day of the main branch receiving new commits, but you won't get the new images unless you manually run docker pull brandoncc/vim-be-good:stable periodically.

docker run -it --rm brandoncc/vim-be-good:stable

"Latest" image

This image runs :PlugUpdate before running neovim. This adds about one second to the startup time of the game. The trade-off is that you are always playing the latest version of the game, as long as your machine is able to access Github.com to pull it.

docker run -it --rm brandoncc/vim-be-good:latest

Playing the games.

Before doing ANYTHING at all, make sure you are in an empty file. If the file you are in is not empty, VimBeGood will throw an error.

Ok, you are in an empty file, so first execute the following.

:VimBeGood

This will echo out the available set of games. Each game can take a set of options to change how it is played, the above help menu should include each game.

Future Games

Please make an issue if you have a command you wish to practice and i'll make it into a game!!

Issues

Please file an issue. But if you do, please run the logger first and paste in the input.

To initialize the logger, add this to your vimrc

let g:vim_be_good_log_file = 1

to get the log file executed :echo stdpath("data") to find the path and then copy paste it into the issues.

Contribute

  • Fork
  • Create a feature branch
  • Make changes
  • Modify the configuration to use local build: ~/.config/nvim/init.vim
    call plug#begin('~/.vim/plugged')
    Plug '/tmp/vim-be-good' " path to your vim-be-good fork
    call plug#end()
You can also just use nvim --cmd "set rtp+=$(pwd)" . to set your current
run time path
  • Make PR

Live on Stream

Everything you see here has been developed on stream at ThePrimeagen. Stop by and troll away. Helpful troll hints would be to complement the size of my hands.

Big shout outs to PolarMutex, Brandon CC (stands for credit card) and TEEEEEEEEEJ @brandoncc @bryall @tjdevries

vim-be-good's People

Contributors

anil9 avatar antonk52 avatar barsv avatar brandoncc avatar bryall avatar dependabot[bot] avatar fl3sh avatar genesistms avatar itsyuka avatar j4p3 avatar jasonhawkharris avatar lpanebr avatar magtastic avatar opti21 avatar polarmutex avatar samnela avatar theprimeagen avatar tjdevries avatar tusharxoxoxo avatar victorgabr 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  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

vim-be-good's Issues

[New feature] Games statistics

It would be nice to save scores to file and later use them to check progression.

I think the file should contain:

  • date
  • game type
  • score
  • difficulty?

hjkl game

How did I not see the sooner? This is literally the biggest complaint when first moving to vim.

Example: always be three keystrokes away from x

// _ = space for visual purposes
// o = starting position
// x = thing to delete
_ _ o
_ _ _
_ x _

This would require jjhx to win.

[New feature] Endless practisce mode

I would like to have an option to disable timeouts and practice as long as I want regardless of my reaction time.

It would be nice if I could set let g:vim_be_good_practice_mode = 1 or select such an option on the game menu.

Idea: Surround things fast

A game that challenges and make user practices surrounding words/terms with different brackets/quotes even using the famous Tim Pope's plugin surround.vim.

Game doesn't start after deleting a line

:VimBeGood command is working (I have vim installed through apt install as I'm on Ubuntu + I installed neovim globally through npm thinking it could maybe solve the problem) and I get the menu screen but after deleting an item nothing happens.

I installed plugin using Plug and I'm using NVIM v0.2.2

Preview with :checkhealth: https://asciinema.org/a/2h1f94vONvNqv4QrEfzt5SIuK

Anyone having a clue why it's not working?

Vary the "DELETE ME" text minimum offset distance with the difficulty level

Currently the offset is fixed if the user set the vim_be_good_delete_me_offset config.

Otherwise the offset is 5 + a random number as seen bellow:

        if (isDefindedUserOffset) {
            offset = Number(
                await game.nvim.getVar("vim_be_good_delete_me_offset"),
            );
            console.log("delete-round#getColumnOffset - userOffset ", offset);
        } else {
            offset = Math.floor(Math.random() * (40 - 5)) + 5;

What if instead we had something like:

var minOffset = {noob: 0, easy: 3, medium: 5, hard: 10, nightmare: 15, tpope: 30};

            offset = Math.floor(Math.random() * (40 - 5)) + minOffset[game.difficulty];

Idea: Substitute words/terms on file and/or across multiple files

One of slowest things you can do in vim is to substitute words/terms/suffix/prefix {pattern} on a file and/or across multiple files. A game that challenges users to apply many substitute techniques could be something interesting, specially when you need to use expressions and flags.

Thanks @ThePrimeagen for your awesome work!

Win state never reached.

When playing the game I am unable to reach win state in any of the game modes (including my own).

Running:
:VimBeGood2 relative

I get the game count down:

  1 Game is starting in 2 ...
~
~
~

Followed by the game state:

  1 Game Started:  1 / 10
  2 When you see a "DELETE ME", relative jump to it
  3 as fast as possible and delete it.
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26                               DELETE ME

If I complete the task and by jumping to line 26 and deleting the contents of the line:

  1 Game Started:  1 / 10
  2 When you see a "DELETE ME", relative jump to it
  3 as fast as possible and delete it.
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26

The game does not register that I have completed the task. This applies to ci{ and my own game that I created.

My :checkhealth for reference:

  2 health#nvim#check
  3 ========================================================================
  4 ## Configuration
  5   - OK: no issues found
  6
  7 ## Performance
  8   - OK: Build type: RelWithDebInfo
  9
 10 ## Remote Plugins
 11   - OK: Up to date
 12
 13 ## terminal
 14   - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
 15   - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
 16   - INFO: $XTERM_VERSION=''
 17   - INFO: $VTE_VERSION=''
 18   - INFO: $TERM_PROGRAM=''
 19   - INFO: $COLORTERM=''
 20   - INFO: $SSH_TTY=''
 21
 22 ## tmux
 23   - OK: escape-time: 0ms
 24   - INFO: $TERM: screen-256color
 25
 26 health#provider#check
 27 ========================================================================
 28 ## Clipboard (optional)
 29   - OK: Clipboard tool found: tmux
 30
 31 ## Python 2 provider (optional)
 32   - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
 33   - INFO: Executable: /usr/bin/python2
 34   - INFO: Python2 version: 2.7.15
 35   - INFO: python2-neovim version: 0.2.0 (outdated; from /usr/lib/python2.7/dist-packages/neovim)
 36   - WARNING: Latest python2-neovim is NOT installed: 0.3.1
 37
 38 ## Python 3 provider (optional)
 39   - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
 40   - INFO: Executable: /usr/bin/python3
 41   - INFO: Python3 version: 3.6.8
 42   - INFO: python3-neovim version: 0.2.0 (outdated; from /usr/lib/python3/dist-packages/neovim)
 43   - WARNING: Latest python3-neovim is NOT installed: 0.3.1
 44
 45 ## Ruby provider (optional)
 46   - WARNING: `ruby` and `gem` must be in $PATH.
 47     - ADVICE:
 48       - Install Ruby and verify that `ruby` and `gem` commands work.
 49
 50 ## Node provider (optional)
 51   - INFO: Node: v12.16.2
 52   - INFO: Host: /usr/local/bin/neovim-node-host
 53   - OK: Latest "neovim" npm is installed: 4.8.0
 54

After debugging, it appears that the lines event does not get invoked on changes to the game state. I confirmed this by adding printouts when checkForWin is called and it was never called. I added a call to checkForWin outside the event and the printout worked.

I attempted to look into the events provided by neovim and if they changed over different versions, but there seems to be very little information regarding the actual events that are available (Perhaps they are shared as part of the original vim documentation, however, I have not looked into that yet).

I am not sure where to look into the events provided by Neovim and if that would be the actual cause of the issue?

Perhaps someone else has insight into this issue?

Port a game for me?

@brandoncc or polarmutex (what was your github name????)

Could you consider porting one game for me? Just to try it out and see how it goes?

After that, the lua lua branch can become master and all those shitty install instructions can go away.

[New feature] Contributor guide

I would like to see simple guide on how to contribute to the project and test it locally.

I don't have any experience with js projects and I need simple steps what do to start to contribute.
Ex:

  • Fork
  • Create a feature branch
  • Make changes
  • Build (command to build here)
  • Modify the configuration to use a locally built plugin
  • Test it
  • Make PR

Something along these lines or just point to the video where these steps are made.

Install with dein

I am using dein.vim as plugin manager
but am unable to start vim-be-good after installing it with it
for installing I am using the following line:

call dein#add('ThePrimeagen/vim-be-good')

And I see that it's installed but the command VimBeGood is not recognized after the install.
I am not so sure how to debug this so will be glad if someone has any ideas or pointers.

invalid method: nvim_create_buf

After installing, when I run VimBeGood I get the following message:

Error: nvim_create_buf: Invalid method: nvim_create_buf

I am guessing that means you need at least Neovim version X. I am on 0.3.2.

Idea: Ctrl-A and Ctrl-O to change numbers

I was coding a game during the steam last night on using Ctrl-a and Ctrl-x to increment and decrement a number to solve a math equation

Not sure if this game will have greater community interest but it is a less known command and pretty useful in certain contexts

I can polish it and submit a PR is there is interest

E492: Not an editor command: VimBeGood

To Reproduce

  1. Create min.vim:
call plug#begin('~/.config/nvim/bundle/')

Plug 'ThePrimeagen/vim-be-good'

call plug#end()
  1. Install vim plug.
  2. nvim -u min.vim
  3. :PlugInstall
  4. :Up
    Output:
function remote#host#UpdateRemotePlugins[6]..<SNR>26_RegistrationCommands[13]..remote#host#RegisterPlugin, line 5
Plugin "/home/jan/.config/nvim/bundle/vim-be-good/rplugin/node/vim-be-good" is already registered
remote/host: generated rplugin manifest: /home/jan/.local/share/nvim/rplugin.vim
  1. :VimBeGood
    Output:
E492: Not an editor command: VimBeGood

[Enhancement] Sentences from vim help as stages for whackamole

Can we use sentences from vim help as stages for whackamole, this force to read a small part of help and learn about a new feature or just remind about forgotten ones?

Even if we jump through the senescent some part of it will remain and will be processed in 'background'.

Floating/Popup buffer

Besides making sure the current buffer is empty, it would be nice to create a new buffer in the floating/popup buffer

Remember Options

We should save config settings such that when you set your options, difficulty, mode, etc etc (more options are inevitable) then we can restore them.

Tiered game system

Especially for random mode it would be nice to have the quad a titles show up more frequently

Quad A (great for any level)
Relative
Whack a mole
Ci

Triple A (good till you become an intermediate vim user)
Hjkl

Double A (not common commands useful in certain contexts)
Something similar to the number game I wrote

Test Suite and CI

With the popularity growing with this library its critical that it stays healthy. I will need to create a test suite to test for basic functionality and CI to ensure every PR keeps it nice. :)

[New feature] Labels for issues

Consider label usage (event build-in) to improve issues readability and searchability.

I think over time the number of issues probably significantly increases as the project will grow. Labels make a lot easier to navigate and search for issues.
Moreover, issues with labels just look cool.

New command or something ...

I actually typed in :VimBeGod yesterday and it got me thinking. A new command like VimBeGod would be pretty cool.
It could start in a new ultra-hard difficulty, which only "Gods" could beat. If you do beat it, your name goes into a hall of fame section in the readme.

Just an idea. I really like the plugin btw.

Result quantity.

First of all, thanks for removing NodeJS from this plugin.

What's the resulting quantity of the score?

image

Seconds? CPU clock cycle? Coconut oils?

Untimed Noob-Mode

Hey there,

at the moment im kinda overwhelmed with the speed of all the games other then 'hjkl' but i also have not used vim a my main editor. I tried 'vim-be-good' and i really like the idea. The only thing is that for me the speed of the refresh is to fast.

Would it be possible to add a "untimed" mode for noobs where yo can take your time to think of the proper vim movement and execute it "in peace"?

Random Gameplay

There should be a mode for random gameplay. Meaning that each game type should be able to be played per round.

New game idea: juggling brackets

A lot of times you need to adjust the number of closing brackets. e.g.

(a(b(c(
  de
  )f)g))))))

Sometimes it can be a combination of {, [, and (.

(a{b[c(
  de
  )f)g])})))

What is the fastest way to achieve this?
Perhaps create a game for this?

Quick way to restart

Is there already a way to quickly restart the game?

Since this is for getting those Vim muscles trained up, I think it's crucial to have an easy way to just restart.

Maybe we could allow for ! in the command to ignore a file that is not empty and just get back to action.

Thanks for the awesome work โœŒ๏ธ

Create Docker image

Having a docker image will allow for more portability.
Folks won't have to install neovim if they are coming from OG vim.
No globally installed npm Packages!

I found this docker image for neovim which might a good starting point.
We can strip it down to the bare necessities and add VimBeGood on top.

[Discussion]: Lua

I am considering switching this plugin to Lua, but I would like to discuss with the core contributors.

Pros

  • Significantly reduces the complexity of installation
    • No External libraries
    • No node requirements
    • No UpdateRemotePlugins requirement
  • There are outstanding windows installation issues #31 #13 that are likely to be resolved by going into native module status.
  • Timings will be significantly more accurate as there is no remote communication.
  • Lua is a very easy language. I am 3 hours into it and feel slightly proficient.
  • Brazilians love Lua (except yshows).
  • Rewriting could potentially be done in piece meal.
  • More people could contribute if its in Lua

Cons

  • Lua rewrite. I don't want to rewrite anything
  • Is it possible to rewrite piece meal?
  • Less people could contribute if its in Lua
  • Unknown challenges when working with Lua. Even though Pro that I felt any form of proficiency, that does not mean it will scale the more I use it.

Thoughts?

@FL3SH @bryall @brandoncc @vegerot @lpanebr

Idea: Jumping vertically over your file

It would be interesting to have a game that challenges the user to visually jump around, the idea is to make you jump fast to where your eyes are looking. Example: Words highlights randomly across file and user have few seconds to jump to it.

E492: Not an editor command

Whenever I try to run :VimBeGood in an empty file (or any file at all) in vim, I get an error saying:
E492: Not an editor command.

I am running NeoVim version 0.4.3 and installed the plugin using VimPlug.

I followed the installation procedure in the README.md and restarted my terminal a few times. Anyone knows how to solve this?

Refactor src/index.ts

Its clear from about 10 days ago that that file sucks. It sucks in every way.

I like where Game and GameBuffer are going. I think they could use a bit more utility. But there appears to be something else that needs to be created. Some sort of runner that runs the game itself. This will allow for a couple things.

  1. index.ts will consist of scaffolding. No real logic within it.
  2. It will allow for what takes its place to be testable. The current setup just sucks. SUCKS.
  3. Have I said I hate that file enough yet? Sorry not Sorry.

Thank you.

PS. I really hate that file.

Quickly changing inside different surroundings

I thought of 3 different challenges:

Replace the contents of "quoted text" with bar.
Replace the contents of 'quoted text' with bar.
Replace the contents of `quoted text` with bar.

The random sentence presented should be something like:

bar `bar` bar "bar" bar bar bar 'bar'.

bar bar "bar 'bar' bar" `bar`.

bar  "bar 'bar' `bar` bar".

bar  "bar 'bar' bar `bar` bar".

The sentence may be randomly generated given that:

  • it always contains the 3 types of surrounding
  • if randomly presents sequential and nested surroundings

Idea: type common/useful command combos to gain speed

Inspiration:

I'm new with dvorak, I'm new with vim. All games are useful for me, but still need to get familiar with something like this:

// Imagine you want to write a simple function
function foo() {
  return "bar";
}

Quite simple but, I needed to learn (improve my muscle memory) to do:

  1. Press i (or o)
  2. Write function as fast as possible (ignore the function name)
  3. Add a pair of ( and ) plus a space plus a { as fast as possible
  4. Now one of the most challenging one (for me): add an enter, add }, press Ctrl+c then Shift+o and finally write the return statement

The same for classes, types, arrow functions, reserved words...

The main goal is to get better with that kind of vim command sequences Ctrl+c Shift+o, Ctrl+c :w, and commonly used chars like $+[{(&=)}]*!|/@-\?^_#. You all have way more experience with vim and could give me more suggestions.

I'll be working on it to learn how to write a plugin, and to get better with the real-programmer-dvorak layout xD

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.