Skip to content

qwavies/smart-backspace.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨ Smart Backspace for Neovim ✨

Neovim plugin to save time removing indentation written in lua. Inspired by the JetBrains IDE IntelliJ's backspace functionality.

🚀 Demo

smart-backspace-showcase.mp4

📦 Installation

📋 Requirements

  • Neovim 0.8.0+

Warning

If using with nvim-autopairs, in require("nvim-autopairs").setup({}), ensure that map_bs = false.

Using 📦 vim.pack:

vim.pack.add({"https://github.com/qwavies/smart-backspace.nvim"})
require("smart-backspace").setup()
Other Plugin Manager Instructions

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 can create an autocmd with an event condition. For example, using 📦 vim.pack:

vim.api.nvim_create_autocmd({ "InsertEnter", "CmdlineEnter" }, {
  once = true,
  callback = function()
    vim.pack.add({"https://github.com/qwavies/smart-backspace.nvim"})
    require("smart-backspace").setup()
  end
})
Other Plugin Manager Instructions

Using lazy.nvim:

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

🧩 Default configuration

Using 📦 vim.pack:

vim.pack.add({"https://github.com/qwavies/smart-backspace.nvim"})
require("smart-backspace").setup({
  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
    "", -- no extension
    "py",
    "hs",
    "md",
    "txt",
  }
})
Other Plugin Manager Instructions

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
      "", -- no extension
      "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!

image

👨‍💻 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!)

About

Make your neovim feel more like an IDE! A neovim plugin giving you context-aware backspace, handling pairs, whitespace and indentation.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages