m4xshen/hardtime.nvim

github github
pluginworkflow
stars 89
issues 2
subscribers 2
forks 0
CREATED

2023-04-24

UPDATED

7 days ago


📃 Introduction

A Neovim plugin helping you establish good command workflow and habit

⚙️ Features

  • Block repeated k j h l within a period of time
  • Print hints about better commands eg: Use C instead of c$
  • Disable arrow keys and mouse
  • Provides customizable options for restricted keys, disabled keys, etc.

Recommended workflow:

  1. Avoid using arrow keys and the mouse.
  2. Use relative jump (eg: 5j 12-) for vertical movement within the screen.
  3. Use CTRL-U CTRL-D CTRL-B CTRL-F gg G for vertical movement outside the screen.
  4. Use word-motion (w W b B e E ge gE) for short-distance horizontal movement.
  5. Use f F t T , ; 0 ^ $ for medium to long-distance horizontal movement.
  6. Use operator + motion/text-object (eg: ci{ y5j dap) whenever possible.
  7. Use % and square bracket commands (see :h [) to jump between brackets.

Learn more in this blog post

⚡ Requirements

📦 Installation

  1. Install via your favorite package manager.
{
  "m4xshen/hardtime.nvim",
  opts = {}
},
use "m4xshen/hardtime.nvim"
Plug "m4xshen/hardtime.nvim"
  1. Setup the plugin in your init.lua. This step is not needed with lazy.nvim if opts is set as above.
require("hardtime").setup()

🔧 Configuration

You can pass your config table into the setup() function or opts if you use lazy.nvim.

Options

  • max_time (number): Maximum time (in milliseconds) to consider key presses as repeated.
  • max_count (number): Maximum count of repeated key presses allowed within the max_time period.
  • disable_mouse (boolean): Disable mouse support.
  • hint (boolean): Enable hint messages for better commands.
  • allow_different_key (boolean): Allow different keys to reset the count.
  • resetting_keys (table of strings): Keys that reset the count.
  • restricted_keys (table of strings): Keys triggering the count mechanism.
  • hint_keys (table of strings): Keys that trigger hint messages.

Default config

local config = {
   max_time = 1000,
   max_count = 2,
   disable_mouse = true,
   hint = true,
   allow_different_key = false,
   resetting_keys = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
      "c", "C", "d", "x", "X", "y", "Y", "p", "P" },
   restricted_keys = { "h", "j", "k", "l", "-", "+", "gj", "gk" },
   hint_keys = { "k", "j", "^", "$", "a", "i", "d", "y", "c", "l" },
   disabled_keys = { "<UP>", "<DOWN>", "<LEFT>", "<RIGHT>" },
   disabled_filetypes = { "qf", "netrw", "NvimTree", "lazy", "mason" }
}