Skip to content

SUSTech-data/wildfire.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔥Wildfire.nvim: Wildfire burns treesitter🌲

A modern successor to wildfire.vim, empowered with the superpower of treesitter.

Incremental and decremental selection

Accelerate selection with count prefix

Quick selection (leverage by treehopper)

Highlights

  • ⚡ Smartly select the inner part of texts
  • count prefix
  • 🌳 Treesitter Integration

Motivation

I’ve found that treesitter’s incremental_selection is particularly handy for text selection. It often allows for selecting the desired text with fewer keystrokes compared to a well-configured wildfire.vim, all without the need to set up intricate text objects.

However, since treesitter relies solely on AST for incremental selection, it tends to be overly aggressive for surrounds. In such case, I have to revert to using text objects for selection, which is annoyed and tripped me up in practical use.

On the other hand, treesitter doesn’t support the count prefix(vim.v.count), which can make it somewhat cumbersome when dealing with longer ranges. Its implementation is also a bit buggy, as you might select an area within the same range(see below).

A picture is worth a thousand words

Usage

The usage is almost the same as wildfire.vim and incremental_selection, You can check out their introduction to get a sense of it.

  • CR Init selection and do incremental selection if you have initilized (so just keep pressing CR).
  • BS Decremental selection.
  • NUM-CR Accelerate selection with count prefix.

This plugin offers a streamlined method for text selection, freeing you from the hassle of configuring and remembering intricate text objects. Plus, initiating this plugin with CR seamlessly transitions you into visual mode. This means you can still harness the power of your preferred text objects without any extra keystrokes (like v-i-b or CR-i-b).

Beyond the basic actions such as yank(CR), delete(d), and change (c), here are a few other awesome tricks up its sleeve:

Tip

This plugin embodies my endeavor to embrace the Helix-inspired select first method. The horizon is vast, and the possibilities limitless. Come, let’s explore the extent of what we can achieve together! 🚀

Installation

{
    "sustech-data/wildfire.nvim",
    event = "VeryLazy",
    dependencies = { "nvim-treesitter/nvim-treesitter" },
    config = function()
        require("wildfire").setup()
    end,
}

Configuration

This plugin is modified based on the official implementation of treesitter, so you can configure it in a very similar manner.

Currently you can only set surroundings with unit width, refer to the default settings below.

{
    surrounds = {
        { "(", ")" },
        { "{", "}" },
        { "<", ">" },
        { "[", "]" },
    },
    keymaps = {
        init_selection = "<CR>",
        node_incremental = "<CR>",
        node_decremental = "<BS>",
    },
    filetype_exclude = { "qf" }, --keymaps will be unset in excluding filetypes
}

To disable a keymaps, set it to nil or false.

The quick selection havn’t support natively, but you can try it out by

:lua require'wildfire'.init_selection()<CR>:lua require('tsht').nodes()<CR>

which is powered by treehopper, flash also provide similar things

Roadmap

  • init with count prefix
  • support configuring exclude filetypes
  • Native quick selection support
  • Advanced surround support (Any length)
  • Handle surround in node

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages