Giter Club home page Giter Club logo

soy's Introduction

Soy

Structural commands for your code in VSCode, without sacrificing speed (thanks to tree-sitter!).

Action Key(s)
Extend Selection ⇧ Shift Alt
Shrink Selection ⇧ Shift Alt
Selection Mode ⇧ Shift ⇧ Shift
Unwrap ⌃ Ctrl ⇧ Shift
Move ⌃ Ctrl ⇧ Shift
⌃ Ctrl ⇧ Shift

Let me know if your language is missing. You can also help by adding it to tree-sitter-wasms.


Looking for a more ambitious (yet more caveated) structured editing extension? Take a look at Tofu!

soy's People

Contributors

gregoor avatar

Stargazers

Zak Miller avatar Ilya Pomaskin avatar Jesús García Martínez avatar  avatar Helder S Ribeiro avatar  avatar andrew blinn avatar

Watchers

 avatar

soy's Issues

`Move left/right` commands are sometimes undoable with their `Move right/left` counterpart

STR:

Open a file with e.g. the following contents:

// orig
const foo = [
  ["first", 23],
  ["second", ≤52≥]
];

( indicates selection start, selection end)

Move the cursor to 52, then use Move left:

// step1
const foo = [
  ["first", 23],
  [≤52≥, "second"]
];

Move left again:

// step2
const foo = [
  [52, "second"],
  ["first", 23]
];

At this point, there is no way to return to the orig state using Move right, you have to use Undo. The way I conceptualize it is that in step2 there's an implicit Expand selection happening which I wasn't expecting. As I write this I'm not quite sure if this is an artificial case but I'm filing since it caught me by surprise at first.

Feature request: add next/previous sibling to selection

const Configs = [
  {
    name: 'Default',
    opts: {
      silent: true
    },
  },
  {
    name: 'Fancy',
    opts: {
      extraVerbose: true,
      prefix: '[Module] '
    }
  },
  {
    name: 'Third',
    opts: {
      unnecessary: 'probably',
    }
  }
];

After using Expand selection to select the entire second member of the array (Fancy), would be nice to have a way to extend the selection to cover Third, or Default. The next Expand selection at that point selects all members of the array.

Convoluted object example used because in the simpler case where each array element is a single line I can use existing shortcuts to add previous/next line to selection to handle this.

Move into/out-of

Atm move is only a swap on the same level. It'd be much more useful if it could also move items within 2+-dimensional collections or move statements into and out-of blocks. Here's a video showing how it works in Tofu:

cdbe75c4682b50a0.mp4

Reparenthesisation aka Reprecedencisation aka Umklammerung

68385939643c6ed7.mp4

(Video of how it works in Tofu)

This will likely require a (hopefully small) amount of language specific work. In most tree-sitter langs' ASTs parenthesized nodes are called parenthesized_expression, but e.g. for a TS type they are called parenthesized_type.

Horizontal/Neighbor Selection

4c85bb4d942d005a.mp4

(Video of how it works in Tofu)

Would also requires some language specific config for selecting quasi neighbors. Likely a list of nodes which's children should be considered quasi-neighbors, namely all operations.

`Shrink selection` while nothing is selected causes cursor to jump to last position where `Expand selection` was used

STR:

In a TSX file, with e.g. the following contents:

import { sum } from 'lodash-es';
import React, { SetStateAction } from 'react';

Put the cursor at the end of the first import, then use Expand selection. Now, move the cursor, which will cause the selection to be dismissed. Finally, use Shrink selection.

Results:

Cursor jumps back to end of the first import.

Expected results:

Nothing happens to the cursor when there's no selection to shrink.

Weird results of `Move` command in chained method calls

const normSpaceText = text
    .replaceAll('\x1F', '')
    .replaceAll(/  +/gu, ' ')
    .replaceAll(/a ?\.k ?\.a/gu, 'aka')
    .replaceAll(/e ?\.g/gu, 'eg')
    .replace(WORD_SEPARATOR_END, '');

I tried to use Move left/right to reorder the calls, but it just does weird stuff. If I move the cursor to the first replace|All (| is cursor) and use Move right this happens:

const normSpaceText = replaceAll
    .text
    .replaceAll('\x1F', '')(/  +/gu, ' ')
    .replaceAll(/a ?\.k ?\.a/gu, 'aka')
    .replaceAll(/e ?\.g/gu, 'eg')
    .replace(WORD_SEPARATOR_END, '');

Are the shortcut default keybindings unobtrusive?

In contrast to Tofu, I want Soy's actions to be non-overwriting extras you choose to use, without interrupting how you already use shortcuts. Thus I wanted to pick shortcuts which are not already taken by common actions.

This issue is for collecting all kinds of thoughts and ideas around that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.