• Stars
    star
    501
  • Rank 88,002 (Top 2 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactively select and swap function arguments, list elements, and much more. Powered by tree-sitter.

iswap.nvim

⚠️ If you're getting an error updating this repository, delete it, and install it again! See #58 for details.

Interactively select and swap: function arguments, list elements, function parameters, and more. Powered by tree-sitter.

demo.mov

installation

For vim-plug:

Plug 'mizlan/iswap.nvim'

usage

Run the command :ISwap when your cursor is in a location that is suitable for swapping around things. These include lists/arrays, function arguments, and parameters in function definitions. Then, hit two keys corresponding to the items you wish to be swapped. After both keys are hit, the text should immediately swap in the buffer. See the gif above for example usage.

Use :ISwapWith if you want to have the element your cursor is over automatically as one of the elements. This way, you only need one keypress to make a swap.

Use :ISwapNode to swap two arbitrary adjacent nodes. Again, :ISwapNodeWith picks the cursor element automatically as one of the elements. :ISwapNodeWith{Left,Right} are provided as shortcuts to swap the cursor node with its immediate left and right node respectively.

For all of the above commands, there is an equivalent :IMove* command that will 'move' the node to the chosen position, rather than swapping. This is equivalent to swapping the first node with all of the nodes up to and including the second node.

configuration

In your init.lua:

require('iswap').setup{
  -- The keys that will be used as a selection, in order
  -- ('asdfghjklqwertyuiopzxcvbnm' by default)
  keys = 'qwertyuiop',

  -- Grey out the rest of the text when making a selection
  -- (enabled by default)
  grey = 'disable',

  -- Highlight group for the sniping value (asdf etc.)
  -- default 'Search'
  hl_snipe = 'ErrorMsg',

  -- Highlight group for the visual selection of terms
  -- default 'Visual'
  hl_selection = 'WarningMsg',

  -- Highlight group for the greyed background
  -- default 'Comment'
  hl_grey = 'LineNr',

  -- Post-operation flashing highlight style,
  -- either 'simultaneous' or 'sequential', or false to disable
  -- default 'sequential'
  flash_style = false,

  -- Highlight group for flashing highlight afterward
  -- default 'IncSearch'
  hl_flash = 'ModeMsg',

  -- Move cursor to the other element in ISwap*With commands
  -- default false
  move_cursor = true,

  -- Automatically swap with only two arguments
  -- default nil
  autoswap = true,

  -- Other default options you probably should not change:
  debug = nil,
  hl_grey_priority = '1000',
}

inspired by hop.nvim and nvim-treesitter-textobjects

More Repositories

1

vim-and-cp

Some helpful bits and pieces for your vimrc
Vim Script
42
star
2

dots-nightly

see mizlan/dotfiles
Lua
41
star
3

delimited.nvim

A tidy, more informative goto_{next,prev} for Neovim
Lua
37
star
4

typst-resume-sans

✨ Pretty resume template written in Typst
Typst
28
star
5

guitar-scale-chart

🎸 Pretty guitar scales in your terminal
Perl
25
star
6

termbufm

Lightweight Terminal Buffer Manager for Neovim.
Vim Script
18
star
7

dotfiles

dotfiles on an m1 mac
Fennel
15
star
8

longbow.nvim

🏹 Aim with efficiency and precision—regardless the target.
Lua
12
star
9

significant-figures

Web frontend + API and Hackage-published library to evaluate complex expressions with significant figures.
Haskell
9
star
10

vim-tierlist

Build clean and simple tierlists ergonomically in pure VimScript
Vim Script
6
star
11

AutofillDuo

Skip the headache of Duo authentication
JavaScript
5
star
12

mizlan.github.io

CSS
5
star
13

ocaml_gram

Manipulate a small simple subset of the OCaml grammar, for educational use
OCaml
4
star
14

colortiles

a familiar game, reimplemented in a friendlier package :)
TypeScript
3
star
15

grid

Graph and visualize shapes on a coordinate plane.
TypeScript
3
star
16

usub

Python
3
star
17

jukebox

Shell
3
star
18

decrypto-knowledgebase

3
star
19

kitty-config

my configuration for the best cross-platform terminal emulator
2
star
20

.emacs.d

Emacs Lisp
2
star
21

transient

transient for neovim (MVP but neogit exists)
Lua
2
star
22

mizlan

2
star
23

featherweight

A lightweight music manager.
Python
2
star
24

vis-config

Lua
2
star
25

AwechordsWebsite

HTML
2
star
26

mzchael.com

TypeScript
2
star
27

aoc2022

Haskell
1
star
28

appel

working through appel's modern compiler implementation in ml, in haskell
Haskell
1
star
29

error-help

Clojure
1
star
30

pagan

Compile and execute a file based on a given set of rules for compilation and execution
Haskell
1
star
31

microscope.nvim

Small Telescope-esque picker thing
Lua
1
star
32

test2

1
star
33

test

TypeScript
1
star
34

vim-lterm

A Neovim plugin targeted at competitive programmers to more easily compile and run code.
Vim Script
1
star
35

.doom.d

Emacs Lisp
1
star
36

noir

Visualize CodinGame runthroughs (with a bit of effort)
JavaScript
1
star
37

geolocation-test

https://mizlan.github.io/geolocation-test
JavaScript
1
star
38

brutus

Compare multiple solutions to algorithmic problems with on-demand generated input.
Python
1
star
39

vim-solaire

Like emacs-solaire-mode but for Vim and Neovim
Vim Script
1
star
40

indexedmap

Purely-functional order-statistic trees
OCaml
1
star
41

recenttrack

Vercel serverless API function for fetching most recent track played. Defaults to querying Spotify, but falls back to Last.fm when Spotify player is inactive
JavaScript
1
star
42

towerfmt

CLI and webserver for automatic translation of Simon Tatham's Towers encoding to Prolog terms.
OCaml
1
star
43

vendetta

WIP: an alternative frontend for the TeachLA Editor written in TypeScript with Mantine UI
TypeScript
1
star