All Projects β†’ max397574 β†’ better-escape.nvim

max397574 / better-escape.nvim

Licence: other
Escape from insert mode without delay when typing

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to better-escape.nvim

jumpwire.nvim
Jump easily between related files.
Stars: ✭ 16 (-90.36%)
Mutual labels:  neovim, nvim-plugin, nvim-lua
nvim-ghost.nvim
πŸ‘» GhostText plugin for Neovim with zero dependencies πŸŽ‰ Supports neovim running inside WSL too! πŸ₯³ Windows/Linux/macOS supported out-of-the-box! πŸ˜„ (Other OSes need python3.6+ installed)
Stars: ✭ 32 (-80.72%)
Mutual labels:  neovim, nvim, nvim-plugin
code runner.nvim
Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
Stars: ✭ 234 (+40.96%)
Mutual labels:  nvim, nvim-plugin, nvim-lua
lesvim
Nvim config focus on Javascript, Typescript, Rust and Lua - πŸš€ πŸ’ͺ ( Fast and Powerfull ) - Deno and other typescript LSP working well together
Stars: ✭ 69 (-58.43%)
Mutual labels:  neovim, nvim, nvim-lua
nvim-bufdel
A Neovim plugin to improve buffer deletion
Stars: ✭ 89 (-46.39%)
Mutual labels:  nvim-plugin, nvim-lua
qf helper.nvim
A collection of improvements for the quickfix buffer
Stars: ✭ 70 (-57.83%)
Mutual labels:  nvim, nvim-plugin
Neovim-from-scratch
πŸ“š A Neovim config designed from scratch to be understandable
Stars: ✭ 3,825 (+2204.22%)
Mutual labels:  nvim, nvim-plugin
vim-lamp
πŸ’‘Language Server Protocol client for Vim.
Stars: ✭ 34 (-79.52%)
Mutual labels:  nvim, nvim-plugin
Vim Yoink
Vim plugin that maintains a yank history to cycle between when pasting
Stars: ✭ 225 (+35.54%)
Mutual labels:  neovim, nvim
nvim-highlite
A colorscheme template that is "lite" on logic for the developer.
Stars: ✭ 163 (-1.81%)
Mutual labels:  nvim, nvim-plugin
cutlass.nvim
Plugin that adds a 'cut' operation separate from 'delete'
Stars: ✭ 78 (-53.01%)
Mutual labels:  nvim, nvim-plugin
Node Client
Nvim Node.js client and plugin host
Stars: ✭ 243 (+46.39%)
Mutual labels:  neovim, nvim
Rnvimr
Make Ranger running in a floating window to communicate with Neovim via RPC
Stars: ✭ 238 (+43.37%)
Mutual labels:  neovim, nvim
Vim Lsp Cxx Highlight
Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
Stars: ✭ 231 (+39.16%)
Mutual labels:  neovim, nvim
monokai.nvim
Monokai theme for Neovim written in Lua.
Stars: ✭ 154 (-7.23%)
Mutual labels:  nvim-plugin, nvim-lua
telescope-zoxide
An extension for telescope.nvim that allows you operate zoxide within Neovim.
Stars: ✭ 126 (-24.1%)
Mutual labels:  nvim, nvim-plugin
virtual-types.nvim
Neovim plugin that shows type annotations as virtual text
Stars: ✭ 171 (+3.01%)
Mutual labels:  nvim, nvim-plugin
dotfiles
My dotfiles for Neovim, Kitty terminal, Zsh, and a few other things.
Stars: ✭ 101 (-39.16%)
Mutual labels:  nvim, nvim-lua
lspcontainers.nvim
Neovim plugin for lspcontainers.
Stars: ✭ 157 (-5.42%)
Mutual labels:  nvim, nvim-plugin
Lsp Status.nvim
Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
Stars: ✭ 201 (+21.08%)
Mutual labels:  neovim, nvim

πŸšͺbetter-escape.nvim

This plugin is the lua version of better_escape.vim, with some additional features and optimizations

A lot of people have mappings like jk or jj to escape insert mode. The problem with this mappings is that whenever you type a j, neovim wait about 100-500ms (depending on your timeoutlen) to see, if you type a j or a k because these are mapped. Only after that time the j will be inserted. Then you always get a delay when typing a j.

This looks like this (see below for a gif):

Screen Shot 2021-10-08 at 16 21 23

✨Features

  • Escape without getting delay when typing in insert mode
  • Customizable mapping and timeout
  • Use multiple mappings
  • Really small and fast

πŸ“¦Installation

Use your favourite package manager and call the setup function.

-- lua with packer.nvim
use {
  "max397574/better-escape.nvim",
  config = function()
    require("better_escape").setup()
  end,
}

βš™οΈCustomization

Call the setup function with your options as arguments.

-- lua, default settings
require("better_escape").setup {
    mapping = {"jk", "jj"}, -- a table with mappings to use
    timeout = vim.o.timeoutlen, -- the time in which the keys must be hit in ms. Use option timeoutlen by default
    clear_empty_lines = false, -- clear line after escaping if there is only whitespace
    keys = "<Esc>", -- keys used for escaping, if it is a function will use the result everytime
    -- example(recommended)
    -- keys = function()
    --   return vim.api.nvim_win_get_cursor(0)[2] > 1 and '<esc>l' or '<esc>'
    -- end,
}

API

require("better_escape").waiting is a boolean indicating that it's waiting for a mapped sequence to complete.

statusline example
function escape_status()
  local ok, m = pcall(require, 'better_escape')
  return ok and m.waiting and '✺' or ""
end

πŸ‘€Demo

mapping

plugin

πŸŽ“How it works

With the mappings there are two tables created. One contains all first characters and one all second characters. Whenever you type a character the plugin checks if it's in any of the two tables If it is in the first one, the plugin starts a timer. If it is in the second, the plugin checks whether the character you typed before is in the table with the first characters.

If this is the case the plugin gets all the indices where the characters are in the tables, then is searches for matches. If there is a match, that means that there is a mapping which has the typed character as second and the previous typed character as first character. The plugin then checks if the time passed since the first character was types is smaller than timoutlen. If this is the case the two characters get deleted and keys get feed or executed.

Like this it is possible that the characters really get inserted and therefore you have no delay after typing one of the characters of your mapping. With the timeoutlen it's still possible to type the characters of your mappings.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].