qwavies/smart-backspace.nvim

github github
editing-support
stars 21
issues 0
subscribers 0
forks 1
CREATED

UPDATED


🚀 Demo

https://github.com/user-attachments/assets/395f18ee-1346-4ac2-8b5c-79597cffe995

📦 Installation

📋 Requirements

  • Neovim 0.8.0+

[!WARNING] If using with nvim-autopairs, in opts, ensure that map_bs = false.

For 💤 lazy.nvim users:

{
  "qwavies/smart-backspace.nvim"
}

For 📦 packer.nvim users:

use {
  "qwavies/smart-backspace.nvim"
}

For 🔌 vim-plug users:

Plug "qwavies/smart-backspace.nvim"

⚙ Configuration

💤 Lazy Loading

If you want to lazy load Smart Backspace, you could set a event condition. For example, if you use lazy.nvim:

{
  "qwavies/smart-backspace.nvim",
  event = {"InsertEnter", "CmdlineEnter"}
}

🧩 Default configuration

Using lazy.nvim:

{
  "qwavies/smart-backspace.nvim",
  opts = {
    enabled = true, -- enables/disables smart-backspace
    silent = true, -- if set to false, it will send a notification if smart-backspace is toggled
    disabled_filetypes = { -- filetypes to automatically disable smart-backspace
      "py",
      "hs",
      "md",
      "txt",
    }
  }
}

⚡ Toggling smart-backspace

Using the :SmartBackspaceToggle command, smart-backspace can be toggled on/off.

You can force a certain state with either :SmartBackspaceToggle on or :SmartBackspaceToggle off

If you want to set a keybind to toggle smart-backspace, you can implement the following into your neovim config:

vim.keymap.set("n", "<leader>bs", "<cmd>SmartBackspaceToggle<CR>", { desc = "Toggle Smart Backspace" })

🥇 Load times

Smart-Backspace prides itself in its almost instant load times.

Compare load times against some other plugins!

👨‍💻 Planned Changes/Additions

  • A :SmartBackspaceToggle command
  • True compatibility with nvim-autopairs, or act as an alternative
    • Delete pairs of brackets like nvim-autopairs
    • Send warning when smart-backspace has been overriden by another file/plugin
  • Using <C-BS> to use as a regular backspace
  • User configuration for more flexibility (feel free to recommend me more configuration changes!)
  • Treesitter integration to distinguish between proper indentation and over-indentation