mechatroner / rainbow_csv

🌈Rainbow CSV - Vim plugin: Highlight columns in CSV and TSV files and run queries in SQL-like language
MIT License
592 stars 22 forks source link

csv_align and csv_shrink to take ranges ? #51

Open carywreams opened 3 weeks ago

carywreams commented 3 weeks ago

Cant the plugin be modified to operate on ranges? I'd like to give it a go unless there's an inherent reason that won't work.

My specific use case is for my tables in markdown files.

e.g.

:.,+10RainbowAlignRange

or

:7,39RainbowShrinkRange

mechatroner commented 3 weeks ago

Thank you for your interest in this project! I don't think there are any fundamental reasons why this wouldn't work, so it would be great if you could implement this. Please send a PR when it is ready. If it is not that hard could you also make it work for visual line mode selection? But if it seems complicated feel free to ignore, even line range support is fine, maybe I will add it myself at some point. It is just that I don't personally use ranges much so I might have a biased perspective on this.

And I would greatly appreciate it if you could add a unit test for this feature otherwise there is a chance that it could break at some point later - I don't typically do a lot of manual testing after refactorings because it is very time-consuming.

carywreams commented 3 weeks ago

First attempt will be to just convert align and shrink to accept a range of lines. I've roughed-in the first parts for align this afternoon. Tomorrow, I take on shrink.

Can you point me to any existing unit tests for the align and shrink functions? maybe I can modify those for this purpose.

Is there any adjacent functionality I should be considering ?

Thanks

mechatroner commented 3 weeks ago

@carywreams Oh no. There are no existing unit tests for align and shrink. I was sure I had them, this is probably because I have such tests for VSCode version of the extension. Ignore my test request please, I will need to start by adding regular align shrink tests. Sorry for the confusion!

mechatroner commented 3 weeks ago

Regarding the adjacent functionality - nothing particular comes to mind, the remaining features should be orthogonal to the alignment because there are no assumptions about how input CSV files are aligned originally i.e. the extension should be robust to any leading/trailing whitespaces