wishlist icon indicating copy to clipboard operation
wishlist copied to clipboard

A version of SplitJoin that works with treesitter

Open LandonSchropp opened this issue 2 years ago • 3 comments

What?

I love the splitjoin.vim plugin. It's been part of my daily workflow for years. However, there are times when it doesn't get things quite right, resulting in syntax errors. I'd love to see a new Neovim version of this plugin that uses treesitter for better accuracy.

Why?

This plugin saves a ton of time for daily development, making it easy to extend code to multiple lines or condense it to one line.

Potential existing implementations:

splitjoin.vim is already really solid. However, I think it could be better with treesitter.

Potential pitfalls:

One of the time-consuming aspects of the original splitjoin is working around individual language issues. Hopefully, treesitter would solve those problems.

LandonSchropp avatar Aug 25 '21 20:08 LandonSchropp

I really like the plugin. ThePrimeagen streams his work (on twitch) on refactor.nvim which goes into the same direction https://github.com/ThePrimeagen/refactoring.nvim and is based on the Refactoring book by Martin Fowler. Treesitter included.

matu3ba avatar Aug 26 '21 17:08 matu3ba

A bit late, but I've been using this for a while and have no complaints: https://github.com/AckslD/nvim-trevJ.lua

kylechui avatar Aug 29 '22 18:08 kylechui

trevJ is fine for splitting lines but it can't join them.

Sure, I can use va}J, for example, but what if I don't want the spaces? No, gJ doesn't work since it doesn't remove the existing spaces.

ObserverOfTime avatar Sep 04 '22 09:09 ObserverOfTime

Hello. I wrote a similar plugin using trееsitter. At the moment, it is not a complete replacement for splitjoin.vim (for example, there is no arrow function conversion in it), but in my cases it's work good. https://github.com/Wansmer/treesj

Wansmer avatar Nov 11 '22 12:11 Wansmer